1 // Copyright (c) 2006-2008 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 5 #ifndef NET_BASE_NET_MODULE_H__ 6 #define NET_BASE_NET_MODULE_H__ 7 8 #include "base/basictypes.h" 9 #include "base/string_piece.h" 10 11 namespace net { 12 13 // Defines global initializers and associated methods for the net module. 14 // 15 // The network module does not have direct access to the way application 16 // resources are stored and fetched by the embedding application (e.g., it 17 // cannot see the ResourceBundle class used by Chrome), so it uses this API to 18 // get access to such resources. 19 // 20 class NetModule { 21 public: 22 typedef base::StringPiece (*ResourceProvider)(int key); 23 24 // Set the function to call when the net module needs resources 25 static void SetResourceProvider(ResourceProvider func); 26 27 // Call the resource provider (if one exists) to get the specified resource. 28 // Returns an empty string if the resource does not exist or if there is no 29 // resource provider. 30 static base::StringPiece GetResource(int key); 31 32 private: 33 DISALLOW_IMPLICIT_CONSTRUCTORS(NetModule); 34 }; 35 36 } // namespace net 37 38 #endif // NET_BASE_NET_MODULE_H__ 39