OLD | NEW |
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" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/extensions/api/log_private/filter_handler.h" | 17 #include "chrome/browser/extensions/api/log_private/filter_handler.h" |
18 #include "chrome/browser/extensions/api/log_private/log_parser.h" | 18 #include "chrome/browser/extensions/api/log_private/log_parser.h" |
19 #include "chrome/browser/extensions/api/log_private/syslog_parser.h" | 19 #include "chrome/browser/extensions/api/log_private/syslog_parser.h" |
20 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h" | 20 #include "chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h" |
21 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
22 #include "chrome/browser/net/chrome_net_log.h" | 22 #include "chrome/browser/net/chrome_net_log.h" |
| 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/common/extensions/api/log_private.h" | 24 #include "chrome/common/extensions/api/log_private.h" |
24 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
25 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
26 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
27 #include "extensions/browser/extension_function.h" | 28 #include "extensions/browser/extension_function.h" |
28 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
29 | 30 |
30 using content::BrowserThread; | 31 using content::BrowserThread; |
31 | 32 |
32 namespace events { | 33 namespace events { |
(...skipping 26 matching lines...) Expand all Loading... |
59 scoped_ptr<LogParser> parser(CreateLogParser(request_it->first)); | 60 scoped_ptr<LogParser> parser(CreateLogParser(request_it->first)); |
60 if (parser) { | 61 if (parser) { |
61 parser->Parse(request_it->second, output, filter_handler); | 62 parser->Parse(request_it->second, output, filter_handler); |
62 } | 63 } |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 } // namespace | 67 } // namespace |
67 | 68 |
68 // static | 69 // static |
69 LogPrivateAPI* LogPrivateAPI::Get(Profile* profile) { | 70 LogPrivateAPI* LogPrivateAPI::Get(content::BrowserContext* context) { |
70 return GetFactoryInstance()->GetForProfile(profile); | 71 return GetFactoryInstance()->GetForProfile(context); |
71 } | 72 } |
72 | 73 |
73 LogPrivateAPI::LogPrivateAPI(Profile* profile) | 74 LogPrivateAPI::LogPrivateAPI(content::BrowserContext* context) |
74 : profile_(profile), logging_net_internals_(false) { | 75 : profile_(Profile::FromBrowserContext(context)), |
75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 76 logging_net_internals_(false) { |
76 content::Source<Profile>(profile)); | 77 registrar_.Add(this, |
| 78 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 79 content::Source<Profile>(profile_)); |
77 } | 80 } |
78 | 81 |
79 LogPrivateAPI::~LogPrivateAPI() { | 82 LogPrivateAPI::~LogPrivateAPI() { |
80 } | 83 } |
81 | 84 |
82 void LogPrivateAPI::StartNetInternalsWatch(const std::string& extension_id) { | 85 void LogPrivateAPI::StartNetInternalsWatch(const std::string& extension_id) { |
83 net_internal_watches_.insert(extension_id); | 86 net_internal_watches_.insert(extension_id); |
84 BrowserThread::PostTask( | 87 BrowserThread::PostTask( |
85 BrowserThread::IO, FROM_HERE, | 88 BrowserThread::IO, FROM_HERE, |
86 base::Bind(&LogPrivateAPI::MaybeStartNetInternalLogging, | 89 base::Bind(&LogPrivateAPI::MaybeStartNetInternalLogging, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 LogPrivateStopNetInternalsWatchFunction:: | 235 LogPrivateStopNetInternalsWatchFunction:: |
233 ~LogPrivateStopNetInternalsWatchFunction() { | 236 ~LogPrivateStopNetInternalsWatchFunction() { |
234 } | 237 } |
235 | 238 |
236 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() { | 239 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() { |
237 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id()); | 240 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id()); |
238 return true; | 241 return true; |
239 } | 242 } |
240 | 243 |
241 } // namespace extensions | 244 } // namespace extensions |
OLD | NEW |