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