Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H _ | |
| 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTORY_H _ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "components/translate/content/browser/browser_cld_data_provider.h" | |
| 10 | |
| 11 namespace content { | |
| 12 class WebContents; | |
| 13 } | |
| 14 | |
| 15 namespace translate { | |
| 16 | |
| 17 // A factory for the Browser side of CLD Data Providers. The embedder should | |
| 18 // set an instance as soon as feasible during startup. The browser process will | |
| 19 // use this factory to create the one BrowserCldDataProvider for each render | |
| 20 // view host in order to communicate with a RendererCldDataProvider in the | |
| 21 // renderer process. For more information on the RendererCldDataProvider, see: | |
| 22 // ../renderer/renderer_cld_data_provider.h | |
| 23 class BrowserCldDataProviderFactory { | |
| 24 public: | |
| 25 BrowserCldDataProviderFactory() {} | |
| 26 virtual ~BrowserCldDataProviderFactory() {} | |
| 27 | |
| 28 // Create and return a new instance of a BrowserCldDataProvider. The default | |
| 29 // implementation of this method produces a no-op BrowserCldDataProvider that | |
| 30 // is suitable only when CLD data has been statically linked. | |
| 31 // Every invocation creates a new provider; the caller is responsible for | |
| 32 // deleting the object when it is no longer needed. | |
| 33 // TODO(andrewhayden) scoped_ptr? | |
|
Andrew Hayden (chromium.org)
2014/11/10 14:06:35
This still needs to be done, and it seems to make
| |
| 34 virtual BrowserCldDataProvider* NewProvider( | |
|
Takashi Toyoshima
2014/11/06 14:34:29
NewProvider() does not sound a consistent name wit
Andrew Hayden (chromium.org)
2014/11/10 14:06:35
I took a look at cs.chromium.org and tried to find
Takashi Toyoshima
2014/11/11 07:16:36
I agreed to use CreateFoo() pattern.
| |
| 35 content::WebContents* web_contents); | |
| 36 | |
| 37 // Returns true if and only if the current instance for this process is not | |
| 38 // NULL. | |
| 39 static bool IsInitialized(); | |
| 40 | |
| 41 // Sets the default factory for this process, i.e. the factory to be used | |
| 42 // unless the embedder calls Set(BrowserCldDataProviderFactory*). This is the | |
| 43 // method that normal (i.e., non-test) Chromium code should use; embedders can | |
| 44 // and should use the unconditional Set(BrowserCldDataProviderFactory*) method | |
| 45 // instead. If a default factory has already been set, this method does | |
| 46 // nothing. | |
| 47 static void SetDefault(BrowserCldDataProviderFactory* instance); | |
| 48 | |
| 49 // Unconditionally sets the factory for this process, overwriting any | |
| 50 // previously-configured default. Normal Chromium code should never use this | |
| 51 // method; it is provided for embedders to inject a factory from outside of | |
| 52 // the Chromium code base. Test code can also use this method to force the | |
| 53 // runtime to have a desired behavior. | |
| 54 static void Set(BrowserCldDataProviderFactory* instance); | |
| 55 | |
| 56 // Returns the instance of the factory previously set by Set()/SetDefault(). | |
| 57 // If no instance has been set, a default factory will be returned that | |
| 58 // produces no-op BrowserCldDataProviders as described by NewProvider(...) | |
| 59 // above. | |
| 60 static BrowserCldDataProviderFactory* Get(); | |
| 61 | |
| 62 private: | |
| 63 DISALLOW_COPY_AND_ASSIGN(BrowserCldDataProviderFactory); | |
| 64 }; | |
| 65 | |
| 66 } // namespace translate | |
| 67 | |
| 68 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_BROWSER_CLD_DATA_PROVIDER_FACTOR Y_H_ | |
| OLD | NEW |