Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
| 5 | #ifndef NET_BASE_NET_MODULE_H__ |
| 6 | #define NET_BASE_NET_MODULE_H__ |
| 7 | |
David Sanders | 8fee53b | 2022-02-22 20:52:17 | [diff] [blame] | 8 | #include "base/memory/scoped_refptr.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 9 | #include "net/base/net_export.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 10 | |
David Sanders | 8fee53b | 2022-02-22 20:52:17 | [diff] [blame] | 11 | namespace base { |
| 12 | class RefCountedMemory; |
| 13 | } |
| 14 | |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 15 | namespace net { |
| 16 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 17 | // 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] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 24 | class NET_EXPORT NetModule { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 25 | public: |
Andrew Grieve | 1e462f3 | 2019-10-10 17:39:53 | [diff] [blame] | 26 | typedef scoped_refptr<base::RefCountedMemory> (*ResourceProvider)(int key); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 27 | |
Peter Boström | 407869b | 2021-10-07 04:42:48 | [diff] [blame] | 28 | NetModule() = delete; |
| 29 | NetModule(const NetModule&) = delete; |
| 30 | NetModule& operator=(const NetModule&) = delete; |
| 31 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 32 | // 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 Grieve | 1e462f3 | 2019-10-10 17:39:53 | [diff] [blame] | 36 | // 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.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 39 | }; |
| 40 | |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 41 | } // namespace net |
| 42 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 43 | #endif // NET_BASE_NET_MODULE_H__ |