blob: 5f366eb0ad42d1df3fb95b79703252cf952c15a5 [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2011 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#ifndef NET_BASE_NET_MODULE_H__
6#define NET_BASE_NET_MODULE_H__
7
David Sanders8fee53b2022-02-22 20:52:178#include "base/memory/scoped_refptr.h"
[email protected]172da1b2011-08-12 15:52:269#include "net/base/net_export.h"
initial.commit586acc5fe2008-07-26 22:42:5210
David Sanders8fee53b2022-02-22 20:52:1711namespace base {
12class RefCountedMemory;
13}
14
[email protected]8ac1a752008-07-31 19:40:3715namespace net {
16
initial.commit586acc5fe2008-07-26 22:42:5217// Defines global initializers and associated methods for the net module.
18//
19// The network module does not have direct access to the way application
20// resources are stored and fetched by the embedding application (e.g., it
21// cannot see the ResourceBundle class used by Chrome), so it uses this API to
22// get access to such resources.
23//
[email protected]172da1b2011-08-12 15:52:2624class NET_EXPORT NetModule {
initial.commit586acc5fe2008-07-26 22:42:5225 public:
Andrew Grieve1e462f32019-10-10 17:39:5326 typedef scoped_refptr<base::RefCountedMemory> (*ResourceProvider)(int key);
initial.commit586acc5fe2008-07-26 22:42:5227
Peter Boström407869b2021-10-07 04:42:4828 NetModule() = delete;
29 NetModule(const NetModule&) = delete;
30 NetModule& operator=(const NetModule&) = delete;
31
initial.commit586acc5fe2008-07-26 22:42:5232 // Set the function to call when the net module needs resources
33 static void SetResourceProvider(ResourceProvider func);
34
35 // Call the resource provider (if one exists) to get the specified resource.
Andrew Grieve1e462f32019-10-10 17:39:5336 // Returns nullptr if the resource does not exist or if there is no resource
37 // provider.
38 static scoped_refptr<base::RefCountedMemory> GetResource(int key);
initial.commit586acc5fe2008-07-26 22:42:5239};
40
[email protected]8ac1a752008-07-31 19:40:3741} // namespace net
42
initial.commit586acc5fe2008-07-26 22:42:5243#endif // NET_BASE_NET_MODULE_H__