| 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/browser/profiles/profile.h" |
| 24 #include "chrome/common/extensions/api/log_private.h" | 24 #include "chrome/common/extensions/api/log_private.h" |
| 25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 27 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
| 28 #include "extensions/browser/extension_function.h" | 28 #include "extensions/browser/extension_function.h" |
| 29 #include "extensions/browser/extension_system.h" | |
| 30 | 29 |
| 31 using content::BrowserThread; | 30 using content::BrowserThread; |
| 32 | 31 |
| 33 namespace events { | 32 namespace events { |
| 34 const char kOnAddNetInternalsEntries[] = "logPrivate.onAddNetInternalsEntries"; | 33 const char kOnAddNetInternalsEntries[] = "logPrivate.onAddNetInternalsEntries"; |
| 35 } // namespace events | 34 } // namespace events |
| 36 | 35 |
| 37 namespace extensions { | 36 namespace extensions { |
| 38 namespace { | 37 namespace { |
| 39 | 38 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void LogPrivateAPI::AddEntriesOnUI(scoped_ptr<base::ListValue> value) { | 126 void LogPrivateAPI::AddEntriesOnUI(scoped_ptr<base::ListValue> value) { |
| 128 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 127 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 129 | 128 |
| 130 for (std::set<std::string>::iterator ix = net_internal_watches_.begin(); | 129 for (std::set<std::string>::iterator ix = net_internal_watches_.begin(); |
| 131 ix != net_internal_watches_.end(); ++ix) { | 130 ix != net_internal_watches_.end(); ++ix) { |
| 132 // Create the event's arguments value. | 131 // Create the event's arguments value. |
| 133 scoped_ptr<base::ListValue> event_args(new base::ListValue()); | 132 scoped_ptr<base::ListValue> event_args(new base::ListValue()); |
| 134 event_args->Append(value->DeepCopy()); | 133 event_args->Append(value->DeepCopy()); |
| 135 scoped_ptr<Event> event(new Event(events::kOnAddNetInternalsEntries, | 134 scoped_ptr<Event> event(new Event(events::kOnAddNetInternalsEntries, |
| 136 event_args.Pass())); | 135 event_args.Pass())); |
| 137 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 136 EventRouter::Get(profile_)->DispatchEventToExtension(*ix, event.Pass()); |
| 138 *ix, event.Pass()); | |
| 139 } | 137 } |
| 140 } | 138 } |
| 141 | 139 |
| 142 void LogPrivateAPI::MaybeStartNetInternalLogging() { | 140 void LogPrivateAPI::MaybeStartNetInternalLogging() { |
| 143 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 141 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 144 if (!logging_net_internals_) { | 142 if (!logging_net_internals_) { |
| 145 g_browser_process->io_thread()->net_log()->AddThreadSafeObserver( | 143 g_browser_process->io_thread()->net_log()->AddThreadSafeObserver( |
| 146 this, net::NetLog::LOG_ALL_BUT_BYTES); | 144 this, net::NetLog::LOG_ALL_BUT_BYTES); |
| 147 logging_net_internals_ = true; | 145 logging_net_internals_ = true; |
| 148 } | 146 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 LogPrivateStopNetInternalsWatchFunction:: | 233 LogPrivateStopNetInternalsWatchFunction:: |
| 236 ~LogPrivateStopNetInternalsWatchFunction() { | 234 ~LogPrivateStopNetInternalsWatchFunction() { |
| 237 } | 235 } |
| 238 | 236 |
| 239 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() { | 237 bool LogPrivateStopNetInternalsWatchFunction::RunImpl() { |
| 240 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id()); | 238 LogPrivateAPI::Get(GetProfile())->StopNetInternalsWatch(extension_id()); |
| 241 return true; | 239 return true; |
| 242 } | 240 } |
| 243 | 241 |
| 244 } // namespace extensions | 242 } // namespace extensions |
| OLD | NEW |