Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: components/translate/content/browser/browser_cld_data_provider_factory.cc

Issue 2034413003: Delete the non-static CLD data source logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to latest master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // NOT DEAD CODE!
6 // This code isn't dead, even if it isn't currently being used. Please refer to:
7 // https://www.chromium.org/developers/how-tos/compact-language-detector-cld-dat a-source-configuration
8
9 #include "components/translate/content/browser/browser_cld_data_provider_factory .h"
10
11 #include "base/lazy_instance.h"
12 #include "base/memory/ptr_util.h"
13 #include "components/translate/content/browser/browser_cld_data_provider.h"
14
15 namespace {
16
17 // The global instance, alive for the entire lifetime of the process.
18 translate::BrowserCldDataProviderFactory* g_instance = NULL;
19
20 // The default factory, which produces no-op instances of BrowserCldDataProvider
21 // suitable for use when CLD data is statically-linked.
22 base::LazyInstance<translate::BrowserCldDataProviderFactory>::Leaky
23 g_wrapped_default = LAZY_INSTANCE_INITIALIZER;
24
25 } // namespace
26
27
28 namespace translate {
29
30 std::unique_ptr<BrowserCldDataProvider>
31 BrowserCldDataProviderFactory::CreateBrowserCldDataProvider(
32 content::WebContents* web_contents) {
33 return base::WrapUnique(new BrowserCldDataProvider);
34 }
35
36 // static
37 bool BrowserCldDataProviderFactory::IsInitialized() {
38 return g_instance != NULL;
39 }
40
41 // static
42 void BrowserCldDataProviderFactory::SetDefault(
43 BrowserCldDataProviderFactory* instance) {
44 if (!IsInitialized()) Set(instance);
45 }
46
47 // static
48 void BrowserCldDataProviderFactory::Set(
49 BrowserCldDataProviderFactory* instance) {
50 g_instance = instance;
51 }
52
53 // static
54 BrowserCldDataProviderFactory* BrowserCldDataProviderFactory::Get() {
55 if (IsInitialized()) return g_instance;
56 return &g_wrapped_default.Get();
57 }
58
59 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698