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

Side by Side Diff: chrome/browser/extensions/api/log_private/log_private_api_chromeos.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/log_private/log_private_api.h" 5 #include "chrome/browser/extensions/api/log_private/log_private_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (parser) { 61 if (parser) {
62 parser->Parse(request_it->second, output, filter_handler); 62 parser->Parse(request_it->second, output, filter_handler);
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 // static 69 // static
70 LogPrivateAPI* LogPrivateAPI::Get(content::BrowserContext* context) { 70 LogPrivateAPI* LogPrivateAPI::Get(content::BrowserContext* context) {
71 return GetFactoryInstance()->GetForProfile(context); 71 return GetFactoryInstance()->Get(context);
72 } 72 }
73 73
74 LogPrivateAPI::LogPrivateAPI(content::BrowserContext* context) 74 LogPrivateAPI::LogPrivateAPI(content::BrowserContext* context)
75 : profile_(Profile::FromBrowserContext(context)), 75 : profile_(Profile::FromBrowserContext(context)),
76 logging_net_internals_(false) { 76 logging_net_internals_(false) {
77 registrar_.Add(this, 77 registrar_.Add(this,
78 chrome::NOTIFICATION_EXTENSION_UNLOADED, 78 chrome::NOTIFICATION_EXTENSION_UNLOADED,
79 content::Source<Profile>(profile_)); 79 content::Source<Profile>(profile_));
80 } 80 }
81 81
82 LogPrivateAPI::~LogPrivateAPI() { 82 LogPrivateAPI::~LogPrivateAPI() {
83 } 83 }
84 84
85 void LogPrivateAPI::StartNetInternalsWatch(const std::string& extension_id) { 85 void LogPrivateAPI::StartNetInternalsWatch(const std::string& extension_id) {
86 net_internal_watches_.insert(extension_id); 86 net_internal_watches_.insert(extension_id);
87 BrowserThread::PostTask( 87 BrowserThread::PostTask(
88 BrowserThread::IO, FROM_HERE, 88 BrowserThread::IO, FROM_HERE,
89 base::Bind(&LogPrivateAPI::MaybeStartNetInternalLogging, 89 base::Bind(&LogPrivateAPI::MaybeStartNetInternalLogging,
90 base::Unretained(this))); 90 base::Unretained(this)));
91 } 91 }
92 92
93 void LogPrivateAPI::StopNetInternalsWatch(const std::string& extension_id) { 93 void LogPrivateAPI::StopNetInternalsWatch(const std::string& extension_id) {
94 net_internal_watches_.erase(extension_id); 94 net_internal_watches_.erase(extension_id);
95 MaybeStopNetInternalLogging(); 95 MaybeStopNetInternalLogging();
96 } 96 }
97 97
98 static base::LazyInstance<ProfileKeyedAPIFactory<LogPrivateAPI> > 98 static base::LazyInstance<BrowserContextKeyedAPIFactory<LogPrivateAPI> >
99 g_factory = LAZY_INSTANCE_INITIALIZER; 99 g_factory = LAZY_INSTANCE_INITIALIZER;
100 100
101 // static 101 // static
102 ProfileKeyedAPIFactory<LogPrivateAPI>* 102 BrowserContextKeyedAPIFactory<LogPrivateAPI>*
103 LogPrivateAPI::GetFactoryInstance() { 103 LogPrivateAPI::GetFactoryInstance() {
104 return &g_factory.Get(); 104 return &g_factory.Get();
105 } 105 }
106 106
107 void LogPrivateAPI::OnAddEntry(const net::NetLog::Entry& entry) { 107 void LogPrivateAPI::OnAddEntry(const net::NetLog::Entry& entry) {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
109 if (!pending_entries_.get()) { 109 if (!pending_entries_.get()) {
110 pending_entries_.reset(new base::ListValue()); 110 pending_entries_.reset(new base::ListValue());
111 BrowserThread::PostDelayedTask( 111 BrowserThread::PostDelayedTask(
112 BrowserThread::IO, FROM_HERE, 112 BrowserThread::IO, FROM_HERE,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 LogPrivateStopNetInternalsWatchFunction:: 235 LogPrivateStopNetInternalsWatchFunction::
236 ~LogPrivateStopNetInternalsWatchFunction() { 236 ~LogPrivateStopNetInternalsWatchFunction() {
237 } 237 }
238 238
239 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() { 239 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() {
240 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id()); 240 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id());
241 return true; 241 return true;
242 } 242 }
243 243
244 } // namespace extensions 244 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/log_private/log_private_api.h ('k') | chrome/browser/extensions/api/management/management_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698