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

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_api.cc

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/streams_private/streams_private_api.h" 5 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/extension_function_registry.h" 13 #include "chrome/browser/extensions/extension_function_registry.h"
14 #include "chrome/browser/extensions/extension_tab_util.h" 14 #include "chrome/browser/extensions/extension_tab_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/extensions/api/streams_private.h" 16 #include "chrome/common/extensions/api/streams_private.h"
17 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/stream_handle.h" 19 #include "content/public/browser/stream_handle.h"
20 #include "extensions/browser/event_router.h" 20 #include "extensions/browser/event_router.h"
21 #include "extensions/browser/extension_system.h" 21 #include "extensions/browser/extension_system.h"
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 namespace streams_private = api::streams_private; 25 namespace streams_private = api::streams_private;
26 26
27 // static 27 // static
28 StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) { 28 StreamsPrivateAPI* StreamsPrivateAPI::Get(content::BrowserContext* context) {
29 return GetFactoryInstance()->GetForProfile(context); 29 return GetFactoryInstance()->Get(context);
30 } 30 }
31 31
32 StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context) 32 StreamsPrivateAPI::StreamsPrivateAPI(content::BrowserContext* context)
33 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) { 33 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) {
34 registrar_.Add(this, 34 registrar_.Add(this,
35 chrome::NOTIFICATION_EXTENSION_UNLOADED, 35 chrome::NOTIFICATION_EXTENSION_UNLOADED,
36 content::Source<Profile>(profile_)); 36 content::Source<Profile>(profile_));
37 } 37 }
38 38
39 StreamsPrivateAPI::~StreamsPrivateAPI() { 39 StreamsPrivateAPI::~StreamsPrivateAPI() {
(...skipping 20 matching lines...) Expand all
60 new Event(streams_private::OnExecuteMimeTypeHandler::kEventName, 60 new Event(streams_private::OnExecuteMimeTypeHandler::kEventName,
61 streams_private::OnExecuteMimeTypeHandler::Create(info))); 61 streams_private::OnExecuteMimeTypeHandler::Create(info)));
62 62
63 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( 63 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
64 extension_id, event.Pass()); 64 extension_id, event.Pass());
65 65
66 GURL url = stream->GetURL(); 66 GURL url = stream->GetURL();
67 streams_[extension_id][url] = make_linked_ptr(stream.release()); 67 streams_[extension_id][url] = make_linked_ptr(stream.release());
68 } 68 }
69 69
70 static base::LazyInstance<ProfileKeyedAPIFactory<StreamsPrivateAPI> > 70 static base::LazyInstance<BrowserContextKeyedAPIFactory<StreamsPrivateAPI> >
71 g_factory = LAZY_INSTANCE_INITIALIZER; 71 g_factory = LAZY_INSTANCE_INITIALIZER;
72 72
73 // static 73 // static
74 ProfileKeyedAPIFactory<StreamsPrivateAPI>* 74 BrowserContextKeyedAPIFactory<StreamsPrivateAPI>*
75 StreamsPrivateAPI::GetFactoryInstance() { 75 StreamsPrivateAPI::GetFactoryInstance() {
76 return g_factory.Pointer(); 76 return g_factory.Pointer();
77 } 77 }
78 78
79 void StreamsPrivateAPI::Observe(int type, 79 void StreamsPrivateAPI::Observe(int type,
80 const content::NotificationSource& source, 80 const content::NotificationSource& source,
81 const content::NotificationDetails& details) { 81 const content::NotificationDetails& details) {
82 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 82 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
83 const Extension* extension = 83 const Extension* extension =
84 content::Details<const UnloadedExtensionInfo>(details)->extension; 84 content::Details<const UnloadedExtensionInfo>(details)->extension;
85 streams_.erase(extension->id()); 85 streams_.erase(extension->id());
86 } 86 }
87 } 87 }
88 } // namespace extensions 88 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698