OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/api/storage/storage_frontend.h" | 5 #include "extensions/browser/api/storage/storage_frontend.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "extensions/browser/api/extensions_api_client.h" | 14 #include "extensions/browser/api/extensions_api_client.h" |
15 #include "extensions/browser/api/storage/leveldb_settings_storage_factory.h" | 15 #include "extensions/browser/api/storage/leveldb_settings_storage_factory.h" |
16 #include "extensions/browser/api/storage/local_value_store_cache.h" | 16 #include "extensions/browser/api/storage/local_value_store_cache.h" |
17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
18 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
19 #include "extensions/browser/extension_system.h" | |
20 #include "extensions/common/api/storage.h" | 19 #include "extensions/common/api/storage.h" |
21 | 20 |
22 using content::BrowserContext; | 21 using content::BrowserContext; |
23 using content::BrowserThread; | 22 using content::BrowserThread; |
24 | 23 |
25 namespace extensions { | 24 namespace extensions { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 base::LazyInstance<BrowserContextKeyedAPIFactory<StorageFrontend> > g_factory = | 28 base::LazyInstance<BrowserContextKeyedAPIFactory<StorageFrontend> > g_factory = |
(...skipping 12 matching lines...) Expand all Loading... |
42 settings_namespace::Namespace settings_namespace, | 41 settings_namespace::Namespace settings_namespace, |
43 const std::string& change_json) OVERRIDE { | 42 const std::string& change_json) OVERRIDE { |
44 // TODO(gdk): This is a temporary hack while the refactoring for | 43 // TODO(gdk): This is a temporary hack while the refactoring for |
45 // string-based event payloads is removed. http://crbug.com/136045 | 44 // string-based event payloads is removed. http://crbug.com/136045 |
46 scoped_ptr<base::ListValue> args(new base::ListValue()); | 45 scoped_ptr<base::ListValue> args(new base::ListValue()); |
47 args->Append(base::JSONReader::Read(change_json)); | 46 args->Append(base::JSONReader::Read(change_json)); |
48 args->Append(new base::StringValue(settings_namespace::ToString( | 47 args->Append(new base::StringValue(settings_namespace::ToString( |
49 settings_namespace))); | 48 settings_namespace))); |
50 scoped_ptr<Event> event(new Event( | 49 scoped_ptr<Event> event(new Event( |
51 core_api::storage::OnChanged::kEventName, args.Pass())); | 50 core_api::storage::OnChanged::kEventName, args.Pass())); |
52 ExtensionSystem::Get(browser_context_)->event_router()-> | 51 EventRouter::Get(browser_context_) |
53 DispatchEventToExtension(extension_id, event.Pass()); | 52 ->DispatchEventToExtension(extension_id, event.Pass()); |
54 } | 53 } |
55 | 54 |
56 private: | 55 private: |
57 BrowserContext* const browser_context_; | 56 BrowserContext* const browser_context_; |
58 }; | 57 }; |
59 | 58 |
60 } // namespace | 59 } // namespace |
61 | 60 |
62 // static | 61 // static |
63 StorageFrontend* StorageFrontend::Get(BrowserContext* context) { | 62 StorageFrontend* StorageFrontend::Get(BrowserContext* context) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // static | 172 // static |
174 BrowserContextKeyedAPIFactory<StorageFrontend>* | 173 BrowserContextKeyedAPIFactory<StorageFrontend>* |
175 StorageFrontend::GetFactoryInstance() { | 174 StorageFrontend::GetFactoryInstance() { |
176 return g_factory.Pointer(); | 175 return g_factory.Pointer(); |
177 } | 176 } |
178 | 177 |
179 // static | 178 // static |
180 const char* StorageFrontend::service_name() { return "StorageFrontend"; } | 179 const char* StorageFrontend::service_name() { return "StorageFrontend"; } |
181 | 180 |
182 } // namespace extensions | 181 } // namespace extensions |
OLD | NEW |