net_module.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_BASE_NET_MODULE_H__
  5. #define NET_BASE_NET_MODULE_H__
  6. #include "base/memory/scoped_refptr.h"
  7. #include "net/base/net_export.h"
  8. namespace base {
  9. class RefCountedMemory;
  10. }
  11. namespace net {
  12. // Defines global initializers and associated methods for the net module.
  13. //
  14. // The network module does not have direct access to the way application
  15. // resources are stored and fetched by the embedding application (e.g., it
  16. // cannot see the ResourceBundle class used by Chrome), so it uses this API to
  17. // get access to such resources.
  18. //
  19. class NET_EXPORT NetModule {
  20. public:
  21. typedef scoped_refptr<base::RefCountedMemory> (*ResourceProvider)(int key);
  22. NetModule() = delete;
  23. NetModule(const NetModule&) = delete;
  24. NetModule& operator=(const NetModule&) = delete;
  25. // Set the function to call when the net module needs resources
  26. static void SetResourceProvider(ResourceProvider func);
  27. // Call the resource provider (if one exists) to get the specified resource.
  28. // Returns nullptr if the resource does not exist or if there is no resource
  29. // provider.
  30. static scoped_refptr<base::RefCountedMemory> GetResource(int key);
  31. };
  32. } // namespace net
  33. #endif // NET_BASE_NET_MODULE_H__