diff options
52 files changed, 279 insertions, 198 deletions
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index ed34a59..ed4cd13 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -25,6 +25,7 @@ component("ash") { "//base:i18n", "//base/third_party/dynamic_annotations", "//cc", + "//components/device_event_log", "//components/user_manager", "//components/wallpaper", "//content/public/browser", diff --git a/ash/ash.gyp b/ash/ash.gyp index 95547b2..c907df0 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -873,6 +873,7 @@ '../base/base.gyp:base_i18n', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../cc/cc.gyp:cc', + '../components/components.gyp:device_event_log_component', '../components/components.gyp:user_manager', '../components/components.gyp:wallpaper', '../content/content.gyp:content_browser', diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc index fb8a669..39d466c 100644 --- a/ash/system/chromeos/network/network_state_list_detailed_view.cc +++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc @@ -29,7 +29,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/device_state.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" diff --git a/ash/system/chromeos/network/tray_network_state_observer.cc b/ash/system/chromeos/network/tray_network_state_observer.cc index c23279e..8d7f181 100644 --- a/ash/system/chromeos/network/tray_network_state_observer.cc +++ b/ash/system/chromeos/network/tray_network_state_observer.cc @@ -9,7 +9,6 @@ #include "ash/system/tray/system_tray.h" #include "base/location.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/ash/system/chromeos/network/tray_vpn.cc b/ash/system/chromeos/network/tray_vpn.cc index d6c71bf..1ac509c 100644 --- a/ash/system/chromeos/network/tray_vpn.cc +++ b/ash/system/chromeos/network/tray_vpn.cc @@ -13,7 +13,6 @@ #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_item_more.h" #include "ash/system/tray/tray_popup_label_button.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "grit/ash_strings.h" diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 72cbc94..81b6f1b 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp @@ -5888,51 +5888,6 @@ All users must sign out to continue. For network logs, see: <ph name="DEVICE_LOG_LINK"><a href="chrome://device-log">chrome://device-log</a></ph> </message> - <message name="IDS_DEVICE_LOG_TITLE" desc="Title of the chrome://device-log page"> - Device Log - </message> - <message name="IDS_DEVICE_AUTO_REFRESH" desc="Instructions for how to auto-refresh the page"> - Add a query param in URL to auto-refresh the page: chrome://device-log/?refresh=<sec> - </message> - <message name="IDS_DEVICE_LOG_REFRESH" desc="Button to refresh device log"> - Refresh - </message> - <message name="IDS_DEVICE_LOG_LEVEL_SHOW" desc="'Show' label before logging level checkboxes"> - Show: - </message> - <message name="IDS_DEVICE_LOG_LEVEL_ERROR" desc="Error logging level checkbox"> - Error - </message> - <message name="IDS_DEVICE_LOG_LEVEL_USER" desc="User logging level checkbox"> - User - </message> - <message name="IDS_DEVICE_LOG_LEVEL_EVENT" desc="Event logging level checkbox"> - Event - </message> - <message name="IDS_DEVICE_LOG_LEVEL_DEBUG" desc="Debug logging level checkbox"> - Debug - </message> - <message name="IDS_DEVICE_LOG_TYPE_LOGIN" desc="Checkbox to enable showing events of type LOGIN"> - Login - </message> - <message name="IDS_DEVICE_LOG_TYPE_NETWORK" desc="Checkbox to enable showing events of type NETWORK"> - Network - </message> - <message name="IDS_DEVICE_LOG_TYPE_POWER" desc="Checkbox to enable showing events of type POWER"> - Power - </message> - <message name="IDS_DEVICE_LOG_FILEINFO" desc="File info checkbox in device event log"> - File Info - </message> - <message name="IDS_DEVICE_LOG_TIME_DETAIL" desc="Detailed timestamps checkbox in device event log"> - Detailed Timestamps - </message> - <message name="IDS_DEVICE_LOG_ENTRY" desc="Format string for lines in chrome://device-log."> - [<ph name="TIMESTAMP">$1<ex>Timestamp</ex></ph>] - <ph name="FILE_INFO">$2<ex>file:123</ex></ph> - <ph name="EVENT_NAME">$3<ex>Event Description</ex></ph> - </message> - <!-- About NFC Debug UI display strings. They aren't being internationalized bacause this page is meant for debugging only. --> <message name="IDS_NFC_DEBUG_TITLE" desc="Title of the debug page meant for developers to test NFC functionality" translateable="false"> NFC API Test Page diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index b9f60b3..28c6724 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -1316,6 +1316,52 @@ and incorrect credentials. Either an attacker is trying to pretend to be <ph nam </message> </if> + <!-- About device logs UI display strings --> + <message name="IDS_DEVICE_LOG_TITLE" desc="Title of the chrome://device-log page"> + Device Log + </message> + <message name="IDS_DEVICE_AUTO_REFRESH" desc="Instructions for how to auto-refresh the page"> + Add a query param in URL to auto-refresh the page: chrome://device-log/?refresh=<sec> + </message> + <message name="IDS_DEVICE_LOG_REFRESH" desc="Button to refresh device log"> + Refresh + </message> + <message name="IDS_DEVICE_LOG_LEVEL_SHOW" desc="'Show' label before logging level checkboxes"> + Show: + </message> + <message name="IDS_DEVICE_LOG_LEVEL_ERROR" desc="Error logging level checkbox"> + Error + </message> + <message name="IDS_DEVICE_LOG_LEVEL_USER" desc="User logging level checkbox"> + User + </message> + <message name="IDS_DEVICE_LOG_LEVEL_EVENT" desc="Event logging level checkbox"> + Event + </message> + <message name="IDS_DEVICE_LOG_LEVEL_DEBUG" desc="Debug logging level checkbox"> + Debug + </message> + <message name="IDS_DEVICE_LOG_TYPE_LOGIN" desc="Checkbox to enable showing events of type LOGIN"> + Login + </message> + <message name="IDS_DEVICE_LOG_TYPE_NETWORK" desc="Checkbox to enable showing events of type NETWORK"> + Network + </message> + <message name="IDS_DEVICE_LOG_TYPE_POWER" desc="Checkbox to enable showing events of type POWER"> + Power + </message> + <message name="IDS_DEVICE_LOG_FILEINFO" desc="File info checkbox in device event log"> + File Info + </message> + <message name="IDS_DEVICE_LOG_TIME_DETAIL" desc="Detailed timestamps checkbox in device event log"> + Detailed Timestamps + </message> + <message name="IDS_DEVICE_LOG_ENTRY" desc="Format string for lines in chrome://device-log."> + [<ph name="TIMESTAMP">$1<ex>Timestamp</ex></ph>] + <ph name="FILE_INFO">$2<ex>file:123</ex></ph> + <ph name="EVENT_NAME">$3<ex>Event Description</ex></ph> + </message> + </messages> </release> </grit> diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 6619495..1f084a9 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -88,6 +88,7 @@ static_library("browser") { "//components/content_settings/core/common", "//components/crx_file", "//components/data_reduction_proxy/core/browser", + "//components/device_event_log", "//components/domain_reliability", "//components/enhanced_bookmarks", "//components/favicon_base", diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 2f13d99..511fed1 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -30,6 +30,7 @@ include_rules = [ "+components/crx_file", "+components/data_reduction_proxy", "+components/network_hints", + "+components/device_event_log", "+components/dom_distiller", "+components/domain_reliability", "+components/enhanced_bookmarks", diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 37f25b8..7cc4156 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -380,10 +380,10 @@ <include name="IDR_IDENTITY_INTERNALS_CSS" file="resources\identity_internals.css" type="BINDATA" /> <include name="IDR_IDENTITY_INTERNALS_JS" file="resources\identity_internals.js" type="BINDATA" /> </if> + <include name="IDR_DEVICE_LOG_UI_HTML" file="resources\device_log_ui\device_log_ui.html" type="BINDATA" /> + <include name="IDR_DEVICE_LOG_UI_JS" file="resources\device_log_ui\device_log_ui.js" type="BINDATA" /> + <include name="IDR_DEVICE_LOG_UI_CSS" file="resources\device_log_ui\device_log_ui.css" type="BINDATA" /> <if expr="chromeos"> - <include name="IDR_DEVICE_LOG_UI_HTML" file="resources\chromeos\device_log_ui\device_log_ui.html" type="BINDATA" /> - <include name="IDR_DEVICE_LOG_UI_JS" file="resources\chromeos\device_log_ui\device_log_ui.js" type="BINDATA" /> - <include name="IDR_DEVICE_LOG_UI_CSS" file="resources\chromeos\device_log_ui\device_log_ui.css" type="BINDATA" /> <include name="IDR_NETWORK_UI_HTML" file="resources\chromeos\network_ui\network_ui.html" type="BINDATA" /> <include name="IDR_NETWORK_UI_JS" file="resources\chromeos\network_ui\network_ui.js" type="BINDATA" /> <include name="IDR_NETWORK_UI_CSS" file="resources\chromeos\network_ui\network_ui.css" type="BINDATA" /> diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index bcba855..cfd3b10 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -105,6 +105,7 @@ #include "chrome/grit/generated_resources.h" #include "chrome/installer/util/google_update_settings.h" #include "components/component_updater/component_updater_service.h" +#include "components/device_event_log/device_event_log.h" #include "components/google/core/browser/google_util.h" #include "components/language_usage_metrics/language_usage_metrics.h" #include "components/metrics/metrics_service.h" @@ -756,6 +757,9 @@ void ChromeBrowserMainParts::ToolkitInitialized() { void ChromeBrowserMainParts::PreMainMessageLoopStart() { TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopStart"); + + device_event_log::Initialize(0 /* default max entries */); + for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreMainMessageLoopStart(); } @@ -1705,6 +1709,7 @@ void ChromeBrowserMainParts::PostDestroyThreads() { browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); master_prefs_.reset(); process_singleton_.reset(); + device_event_log::Shutdown(); // We need to do this check as late as possible, but due to modularity, this // may be the last point in Chrome. This would be more effective if done at diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl.cc b/chrome/browser/chromeos/net/network_portal_detector_impl.cc index c83cc0d..e7845fb 100644 --- a/chrome/browser/chromeos/net/network_portal_detector_impl.cc +++ b/chrome/browser/chromeos/net/network_portal_detector_impl.cc @@ -15,10 +15,10 @@ #include "chrome/browser/chrome_notification_types.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/shill_profile_client.h" -#include "chromeos/device_event_log.h" #include "chromeos/login/login_state.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" +#include "components/device_event_log/device_event_log.h" #include "content/public/browser/notification_service.h" #include "content/public/common/content_switches.h" #include "net/http/http_status_code.h" diff --git a/chrome/browser/chromeos/system_logs/device_event_log_source.cc b/chrome/browser/chromeos/system_logs/device_event_log_source.cc index 552a583..0fb8a01 100644 --- a/chrome/browser/chromeos/system_logs/device_event_log_source.cc +++ b/chrome/browser/chromeos/system_logs/device_event_log_source.cc @@ -5,7 +5,7 @@ #include "chrome/browser/chromeos/system_logs/device_event_log_source.h" #include "base/message_loop/message_loop.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" #include "content/public/browser/browser_thread.h" namespace system_logs { @@ -25,16 +25,12 @@ void DeviceEventLogSource::Fetch(const SysLogsSourceCallback& callback) { scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); const int kMaxDeviceEventsForAboutSystem = 400; - (*response)[kNetworkEventLogEntry] = chromeos::device_event_log::GetAsString( - chromeos::device_event_log::OLDEST_FIRST, "time,file,level", - "network", - chromeos::device_event_log::kDefaultLogLevel, - kMaxDeviceEventsForAboutSystem); - (*response)[kDeviceEventLogEntry] = chromeos::device_event_log::GetAsString( - chromeos::device_event_log::OLDEST_FIRST, "time,file,type,level", - "non-network", - chromeos::device_event_log::LOG_LEVEL_DEBUG, - kMaxDeviceEventsForAboutSystem); + (*response)[kNetworkEventLogEntry] = device_event_log::GetAsString( + device_event_log::OLDEST_FIRST, "time,file,level", "network", + device_event_log::kDefaultLogLevel, kMaxDeviceEventsForAboutSystem); + (*response)[kDeviceEventLogEntry] = device_event_log::GetAsString( + device_event_log::OLDEST_FIRST, "time,file,type,level", "non-network", + device_event_log::LOG_LEVEL_DEBUG, kMaxDeviceEventsForAboutSystem); callback.Run(response.get()); } diff --git a/chrome/browser/resources/chromeos/device_log_ui/OWNERS b/chrome/browser/resources/device_log_ui/OWNERS index aa215c7..aa215c7 100644 --- a/chrome/browser/resources/chromeos/device_log_ui/OWNERS +++ b/chrome/browser/resources/device_log_ui/OWNERS diff --git a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.css b/chrome/browser/resources/device_log_ui/device_log_ui.css index 3a8ea55..3a8ea55 100644 --- a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.css +++ b/chrome/browser/resources/device_log_ui/device_log_ui.css diff --git a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.html b/chrome/browser/resources/device_log_ui/device_log_ui.html index 6d46248..6d46248 100644 --- a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.html +++ b/chrome/browser/resources/device_log_ui/device_log_ui.html diff --git a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.js b/chrome/browser/resources/device_log_ui/device_log_ui.js index a562ed7..a562ed7 100644 --- a/chrome/browser/resources/chromeos/device_log_ui/device_log_ui.js +++ b/chrome/browser/resources/device_log_ui/device_log_ui.js diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 35a9b45..0bbbcce 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -24,6 +24,7 @@ #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/browser/ui/webui/copresence_ui.h" #include "chrome/browser/ui/webui/crashes_ui.h" +#include "chrome/browser/ui/webui/device_log_ui.h" #include "chrome/browser/ui/webui/domain_reliability_internals_ui.h" #include "chrome/browser/ui/webui/downloads_ui.h" #include "chrome/browser/ui/webui/flags_ui.h" @@ -111,7 +112,6 @@ #include "chrome/browser/ui/webui/chromeos/certificate_manager_dialog_ui.h" #include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h" #include "chrome/browser/ui/webui/chromeos/cryptohome_ui.h" -#include "chrome/browser/ui/webui/chromeos/device_log_ui.h" #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h" #include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h" #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" @@ -297,6 +297,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, return &NewWebUI<ConstrainedWebDialogUI>; if (url.host() == chrome::kChromeUICrashesHost) return &NewWebUI<CrashesUI>; + if (url.host() == chrome::kChromeUIDeviceLogHost) + return &NewWebUI<chromeos::DeviceLogUI>; if (url.host() == chrome::kChromeUIDomainReliabilityInternalsHost) return &NewWebUI<DomainReliabilityInternalsUI>; if (url.host() == chrome::kChromeUIFlagsHost) @@ -412,8 +414,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, return &NewWebUI<chromeos::ChooseMobileNetworkUI>; if (url.host() == chrome::kChromeUICryptohomeHost) return &NewWebUI<chromeos::CryptohomeUI>; - if (url.host() == chrome::kChromeUIDeviceLogHost) - return &NewWebUI<chromeos::DeviceLogUI>; if (url.host() == chrome::kChromeUIDriveInternalsHost) return &NewWebUI<chromeos::DriveInternalsUI>; if (url.host() == chrome::kChromeUIImageBurnerHost) diff --git a/chrome/browser/ui/webui/chromeos/network_ui.cc b/chrome/browser/ui/webui/chromeos/network_ui.cc index 66df036..cadfb75 100644 --- a/chrome/browser/ui/webui/chromeos/network_ui.cc +++ b/chrome/browser/ui/webui/chromeos/network_ui.cc @@ -11,11 +11,11 @@ #include "chrome/browser/extensions/tab_helper.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/device_state.h" #include "chromeos/network/network_configuration_handler.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" +#include "components/device_event_log/device_event_log.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" diff --git a/chrome/browser/ui/webui/chromeos/device_log_ui.cc b/chrome/browser/ui/webui/device_log_ui.cc index cfd47e3..6231da6 100644 --- a/chrome/browser/ui/webui/chromeos/device_log_ui.cc +++ b/chrome/browser/ui/webui/device_log_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/chromeos/device_log_ui.h" +#include "chrome/browser/ui/webui/device_log_ui.h" #include <string> @@ -10,8 +10,9 @@ #include "base/bind_helpers.h" #include "base/values.h" #include "chrome/common/url_constants.h" +#include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" @@ -31,15 +32,14 @@ class DeviceLogMessageHandler : public content::WebUIMessageHandler { void RegisterMessages() override { web_ui()->RegisterMessageCallback( "DeviceLog.getLog", - base::Bind(&DeviceLogMessageHandler::GetLog, - base::Unretained(this))); + base::Bind(&DeviceLogMessageHandler::GetLog, base::Unretained(this))); } private: void GetLog(const base::ListValue* value) const { - base::StringValue data(chromeos::device_event_log::GetAsString( - chromeos::device_event_log::NEWEST_FIRST, "json", "", - chromeos::device_event_log::LOG_LEVEL_DEBUG, 0)); + base::StringValue data(device_event_log::GetAsString( + device_event_log::NEWEST_FIRST, "json", "", + device_event_log::LOG_LEVEL_DEBUG, 0)); web_ui()->CallJavascriptFunction("DeviceLogUI.getLogCallback", data); } @@ -78,8 +78,8 @@ DeviceLogUI::DeviceLogUI(content::WebUI* web_ui) html->AddResourcePath("device_log_ui.js", IDR_DEVICE_LOG_UI_JS); html->SetDefaultResource(IDR_DEVICE_LOG_UI_HTML); - content::WebUIDataSource::Add( - web_ui->GetWebContents()->GetBrowserContext(), html); + content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), + html); } DeviceLogUI::~DeviceLogUI() { diff --git a/chrome/browser/ui/webui/chromeos/device_log_ui.h b/chrome/browser/ui/webui/device_log_ui.h index 343985b..e08a33d 100644 --- a/chrome/browser/ui/webui/chromeos/device_log_ui.h +++ b/chrome/browser/ui/webui/device_log_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_DEVICE_LOG_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_DEVICE_LOG_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_DEVICE_LOG_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_DEVICE_LOG_UI_H_ #include "content/public/browser/web_ui_controller.h" @@ -20,4 +20,4 @@ class DeviceLogUI : public content::WebUIController { } // namespace chromeos -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_DEVICE_LOG_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_DEVICE_LOG_UI_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index ac95635..e520c87 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -906,8 +906,6 @@ 'browser/ui/webui/chromeos/cryptohome_ui.h', 'browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc', 'browser/ui/webui/chromeos/cryptohome_web_ui_handler.h', - 'browser/ui/webui/chromeos/device_log_ui.cc', - 'browser/ui/webui/chromeos/device_log_ui.h', 'browser/ui/webui/chromeos/drive_internals_ui.cc', 'browser/ui/webui/chromeos/drive_internals_ui.h', 'browser/ui/webui/chromeos/first_run/first_run_actor.cc', @@ -1030,6 +1028,8 @@ 'browser/ui/webui/cookies_tree_model_util.h', 'browser/ui/webui/crashes_ui.cc', 'browser/ui/webui/crashes_ui.h', + 'browser/ui/webui/device_log_ui.cc', + 'browser/ui/webui/device_log_ui.h', 'browser/ui/webui/domain_reliability_internals_ui.cc', 'browser/ui/webui/domain_reliability_internals_ui.h', 'browser/ui/webui/favicon_source.cc', @@ -2662,6 +2662,7 @@ 'common', 'common_net', '../components/components.gyp:auto_login_parser', + '../components/components.gyp:device_event_log_component', '../components/components.gyp:dom_distiller_core', '../components/components.gyp:dom_distiller_webui', '../components/components.gyp:feedback_proto', diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 82ed02b..fa1e0a6 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -172,6 +172,7 @@ const char kChromeUICrashesHost[] = "crashes"; const char kChromeUICrashHost[] = "crash"; const char kChromeUICreditsHost[] = "credits"; const char kChromeUIDefaultHost[] = "version"; +const char kChromeUIDeviceLogHost[] = "device-log"; const char kChromeUIDevicesHost[] = "devices"; const char kChromeUIDevToolsHost[] = "devtools"; const char kChromeUIDevToolsBundledPath[] = "bundled"; @@ -274,7 +275,6 @@ const char kChromeUIBluetoothPairingHost[] = "bluetooth-pairing"; const char kChromeUICertificateManagerHost[] = "certificate-manager"; const char kChromeUIChooseMobileNetworkHost[] = "choose-mobile-network"; const char kChromeUICryptohomeHost[] = "cryptohome"; -const char kChromeUIDeviceLogHost[] = "device-log"; const char kChromeUIDiscardsHost[] = "discards"; const char kChromeUIFirstRunHost[] = "first-run"; const char kChromeUIIdleLogoutDialogHost[] = "idle-logout"; @@ -586,6 +586,7 @@ const char* const kChromeHostURLs[] = { kChromeUIComponentsHost, kChromeUICrashesHost, kChromeUICreditsHost, + kChromeUIDeviceLogHost, kChromeUIDNSHost, kChromeUIFlagsHost, kChromeUIHistoryHost, @@ -642,7 +643,6 @@ const char* const kChromeHostURLs[] = { kChromeUICertificateManagerHost, kChromeUIChooseMobileNetworkHost, kChromeUICryptohomeHost, - kChromeUIDeviceLogHost, kChromeUIDiscardsHost, kChromeUIDriveInternalsHost, kChromeUIFirstRunHost, diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 9278dfc..7bcf524 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -164,6 +164,7 @@ extern const char kChromeUICrashesHost[]; extern const char kChromeUICrashHost[]; extern const char kChromeUICreditsHost[]; extern const char kChromeUIDefaultHost[]; +extern const char kChromeUIDeviceLogHost[]; extern const char kChromeUIDevicesHost[]; extern const char kChromeUIDevToolsHost[]; extern const char kChromeUIDevToolsBundledPath[]; @@ -266,7 +267,6 @@ extern const char kChromeUIBluetoothPairingHost[]; extern const char kChromeUICertificateManagerHost[]; extern const char kChromeUIChooseMobileNetworkHost[]; extern const char kChromeUICryptohomeHost[]; -extern const char kChromeUIDeviceLogHost[]; extern const char kChromeUIDiagnosticsHost[]; extern const char kChromeUIDiscardsHost[]; extern const char kChromeUIFirstRunHost[]; diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index 5e5c3b8..40823e6 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn @@ -25,6 +25,7 @@ component("chromeos") { "//base:prefs", "//base/third_party/dynamic_annotations", "//chromeos/ime:gencode", + "//components/device_event_log", "//components/policy/proto", "//components/onc", "//crypto", diff --git a/chromeos/DEPS b/chromeos/DEPS index 8bc2f79..ecef880 100644 --- a/chromeos/DEPS +++ b/chromeos/DEPS @@ -2,6 +2,7 @@ # low level Chrome OS system library that may be used by targets that need to # be kept as small as possible. include_rules = [ + "+components/device_event_log", "+crypto", "+net", "+policy/proto", diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 095c64e..00a41dd 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -260,10 +260,6 @@ 'dbus/update_engine_client.h', 'dbus/volume_state.cc', 'dbus/volume_state.h', - 'device_event_log.cc', - 'device_event_log.h', - 'device_event_log_impl.cc', - 'device_event_log_impl.h', 'disks/disk_mount_manager.cc', 'disks/disk_mount_manager.h', 'geolocation/geoposition.cc', @@ -463,7 +459,6 @@ 'dbus/shill_profile_client_unittest.cc', 'dbus/shill_service_client_unittest.cc', 'dbus/shill_third_party_vpn_driver_client_unittest.cc', - 'device_event_log_impl_unittest.cc', 'disks/disk_mount_manager_unittest.cc', 'geolocation/simple_geolocation_unittest.cc', 'login/auth/key_unittest.cc', @@ -516,6 +511,7 @@ '../build/linux/system.gyp:dbus', '../build/linux/system.gyp:ssl', '../components/components.gyp:cloud_policy_proto', + '../components/components.gyp:device_event_log_component', '../components/components.gyp:onc_component', '../crypto/crypto.gyp:crypto', '../dbus/dbus.gyp:dbus', diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index f74886b..03c620a 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -50,7 +50,6 @@ #include "chromeos/dbus/sms_client.h" #include "chromeos/dbus/system_clock_client.h" #include "chromeos/dbus/update_engine_client.h" -#include "chromeos/device_event_log.h" #include "dbus/bus.h" #include "dbus/dbus_statistics.h" @@ -61,7 +60,6 @@ static bool g_using_dbus_thread_manager_for_testing = false; DBusThreadManager::DBusThreadManager(scoped_ptr<DBusClientBundle> client_bundle) : client_bundle_(client_bundle.Pass()) { - device_event_log::Initialize(0 /* default max entries */); dbus::statistics::Initialize(); if (client_bundle_->IsUsingAnyRealClient()) { @@ -95,7 +93,6 @@ DBusThreadManager::~DBusThreadManager() { dbus_thread_->Stop(); dbus::statistics::Shutdown(); - device_event_log::Shutdown(); if (!g_dbus_thread_manager) return; // Called form Shutdown() or local test instance. diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc index 6840dcf..961ad4c 100644 --- a/chromeos/dbus/power_manager_client.cc +++ b/chromeos/dbus/power_manager_client.cc @@ -27,7 +27,7 @@ #include "chromeos/dbus/power_manager/policy.pb.h" #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" #include "chromeos/dbus/power_manager/suspend.pb.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_path.h" diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc index 6418015..8100355 100644 --- a/chromeos/dbus/shill_client_helper.cc +++ b/chromeos/dbus/shill_client_helper.cc @@ -7,7 +7,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/values.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" #include "dbus/message.h" #include "dbus/object_proxy.h" #include "dbus/values_util.h" diff --git a/chromeos/login/login_state.cc b/chromeos/login/login_state.cc index ae8403c..07a7f6b 100644 --- a/chromeos/login/login_state.cc +++ b/chromeos/login/login_state.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/sys_info.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" namespace chromeos { diff --git a/chromeos/network/network_device_handler_impl.cc b/chromeos/network/network_device_handler_impl.cc index 54a414c..8755b56 100644 --- a/chromeos/network/network_device_handler_impl.cc +++ b/chromeos/network/network_device_handler_impl.cc @@ -13,10 +13,10 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_ipconfig_client.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/device_state.h" #include "chromeos/network/network_handler_callbacks.h" #include "chromeos/network/network_state_handler.h" +#include "components/device_event_log/device_event_log.h" #include "dbus/object_path.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/chromeos/network/network_event_log.h b/chromeos/network/network_event_log.h index 104da00..7c2ba92 100644 --- a/chromeos/network/network_event_log.h +++ b/chromeos/network/network_event_log.h @@ -12,7 +12,7 @@ #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "chromeos/chromeos_export.h" -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" namespace base { class Value; @@ -44,26 +44,26 @@ CHROMEOS_EXPORT std::string ValueAsString(const base::Value& value); // Errors #define NET_LOG_ERROR(event, desc) \ - NET_LOG_LEVEL(::chromeos::device_event_log::LOG_LEVEL_ERROR, event, desc) + NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_ERROR, event, desc) // Chrome initiated events, e.g. connection requests, scan requests, // configuration removal (either from the UI or from ONC policy application). #define NET_LOG_USER(event, desc) \ - NET_LOG_LEVEL(::chromeos::device_event_log::LOG_LEVEL_USER, event, desc) + NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_USER, event, desc) // Important events, e.g. state updates #define NET_LOG_EVENT(event, desc) \ - NET_LOG_LEVEL(::chromeos::device_event_log::LOG_LEVEL_EVENT, event, desc) + NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_EVENT, event, desc) // Non-essential debugging events #define NET_LOG_DEBUG(event, desc) \ - NET_LOG_LEVEL(::chromeos::device_event_log::LOG_LEVEL_DEBUG, event, desc) + NET_LOG_LEVEL(::device_event_log::LOG_LEVEL_DEBUG, event, desc) // Macro to include file and line number info in the event log. -#define NET_LOG_LEVEL(log_level, event, description) \ - ::chromeos::device_event_log::AddEntryWithDescription( \ - __FILE__, __LINE__, ::chromeos::device_event_log::LOG_TYPE_NETWORK, \ - log_level, event, description) +#define NET_LOG_LEVEL(log_level, event, description) \ + ::device_event_log::AddEntryWithDescription( \ + __FILE__, __LINE__, ::device_event_log::LOG_TYPE_NETWORK, log_level, \ + event, description) } // namespace network_event_log diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc index 1843a69..bd53eae 100644 --- a/chromeos/network/network_state.cc +++ b/chromeos/network/network_state.cc @@ -7,12 +7,12 @@ #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/network_profile_handler.h" #include "chromeos/network/network_type_pattern.h" #include "chromeos/network/network_util.h" #include "chromeos/network/onc/onc_utils.h" #include "chromeos/network/shill_property_util.h" +#include "components/device_event_log/device_event_log.h" #include "third_party/cros_system_api/dbus/service_constants.h" namespace { diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc index 7982459..941630c 100644 --- a/chromeos/network/shill_property_util.cc +++ b/chromeos/network/shill_property_util.cc @@ -12,9 +12,9 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversion_utils.h" #include "base/values.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/network_ui_data.h" #include "chromeos/network/onc/onc_utils.h" +#include "components/device_event_log/device_event_log.h" #include "third_party/cros_system_api/dbus/service_constants.h" namespace chromeos { diff --git a/components/BUILD.gn b/components/BUILD.gn index 97417d0..7312e28 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn @@ -33,6 +33,7 @@ group("all_components") { "//components/crx_file", "//components/data_reduction_proxy/core/browser", "//components/data_reduction_proxy/core/common", + "//components/device_event_log", "//components/dom_distiller/core", "//components/domain_reliability", "//components/enhanced_bookmarks", @@ -237,6 +238,7 @@ if (!is_win || link_chrome_on_windows) { "//components/crx_file:unit_tests", "//components/data_reduction_proxy/core/browser:unit_tests", "//components/data_reduction_proxy/core/common:unit_tests", + "//components/device_event_log:unit_tests", "//components/dom_distiller/core:unit_tests", "//components/domain_reliability:unit_tests", "//components/favicon_base:unit_tests", diff --git a/components/components.gyp b/components/components.gyp index 39e07f7..db6d9b0 100644 --- a/components/components.gyp +++ b/components/components.gyp @@ -21,6 +21,7 @@ 'cronet.gypi', 'crx_file.gypi', 'data_reduction_proxy.gypi', + 'device_event_log.gypi', 'network_hints.gypi', 'dom_distiller.gypi', 'domain_reliability.gypi', diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 3287ead..cfd77f5 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -136,6 +136,7 @@ 'data_reduction_proxy/core/common/data_reduction_proxy_event_store_unittest.cc', 'data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc', 'data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc', + 'device_event_log/device_event_log_impl_unittest.cc', 'dom_distiller/core/article_entry_unittest.cc', 'dom_distiller/core/distilled_content_store_unittest.cc', 'dom_distiller/core/distilled_page_prefs_unittests.cc', @@ -391,6 +392,7 @@ 'components.gyp:data_reduction_proxy_core_browser', 'components.gyp:data_reduction_proxy_core_common', 'components.gyp:data_reduction_proxy_test_support', + 'components.gyp:device_event_log_component', 'components.gyp:distilled_page_proto', 'components.gyp:dom_distiller_core', 'components.gyp:dom_distiller_test_support', diff --git a/components/device_event_log.gypi b/components/device_event_log.gypi new file mode 100644 index 0000000..09eda0e --- /dev/null +++ b/components/device_event_log.gypi @@ -0,0 +1,28 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'device_event_log_component', + 'type': '<(component)', + 'dependencies': [ + '../base/base.gyp:base', + '../net/net.gyp:net', + ], + 'include_dirs': [ + '..', + ], + 'defines': [ + 'DEVICE_EVENT_LOG_IMPLEMENTATION', + ], + 'sources': [ + 'device_event_log/device_event_log.cc', + 'device_event_log/device_event_log.h', + 'device_event_log/device_event_log_impl.cc', + 'device_event_log/device_event_log_impl.h', + ], + }, + ], +} diff --git a/components/device_event_log/BUILD.gn b/components/device_event_log/BUILD.gn new file mode 100644 index 0000000..0b1103b --- /dev/null +++ b/components/device_event_log/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("device_event_log") { + sources = [ + "device_event_log.cc", + "device_event_log.h", + "device_event_log_impl.cc", + "device_event_log_impl.h", + ] + + deps = [ + "//base", + "//net", + ] +} + +source_set("unit_tests") { + testonly = true + sources = [ + "device_event_log_impl_unittest.cc", + ] + + deps = [ + ":device_event_log", + "//testing/gtest", + ] +} diff --git a/components/device_event_log/DEPS b/components/device_event_log/DEPS new file mode 100644 index 0000000..8fa9d48 --- /dev/null +++ b/components/device_event_log/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+net", +] diff --git a/components/device_event_log/OWNERS b/components/device_event_log/OWNERS new file mode 100644 index 0000000..d313f84 --- /dev/null +++ b/components/device_event_log/OWNERS @@ -0,0 +1,2 @@ +stevenjb@chromium.org +reillyg@chromium.org diff --git a/chromeos/device_event_log.cc b/components/device_event_log/device_event_log.cc index aaded58..0d52b6a 100644 --- a/chromeos/device_event_log.cc +++ b/components/device_event_log/device_event_log.cc @@ -2,14 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/device_event_log.h" +#include "components/device_event_log/device_event_log.h" #include <string> #include "base/logging.h" -#include "chromeos/device_event_log_impl.h" - -namespace chromeos { +#include "components/device_event_log/device_event_log_impl.h" namespace device_event_log { @@ -106,5 +104,3 @@ ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() { } // namespace internal } // namespace device_event_log - -} // namespace chromeos diff --git a/chromeos/device_event_log.h b/components/device_event_log/device_event_log.h index a71f8d6..cc733e4 100644 --- a/chromeos/device_event_log.h +++ b/components/device_event_log/device_event_log.h @@ -2,19 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DEVICE_EVENT_LOG_H_ -#define CHROMEOS_DEVICE_EVENT_LOG_H_ +#ifndef COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_H_ +#define COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_H_ #include <cstring> #include <sstream> #include "base/basictypes.h" #include "base/timer/elapsed_timer.h" -#include "chromeos/chromeos_export.h" +#include "components/device_event_log/device_event_log_export.h" -namespace chromeos { - -// These macros can be used to log chromeos device related events. +// These macros can be used to log device related events. // The following values should be used for |level| in these macros: // ERROR Unexpected events, or device level failures. Use sparingly. // USER Events initiated directly by a user (or Chrome) action. @@ -24,31 +22,31 @@ namespace chromeos { // NET_LOG(EVENT) << "NetworkState Changed " << name << ": " << state; // POWER_LOG(USER) << "Suspend requested"; -#define NET_LOG(level) \ - DEVICE_LOG(::chromeos::device_event_log::LOG_TYPE_NETWORK, \ - ::chromeos::device_event_log::LOG_LEVEL_##level) -#define POWER_LOG(level) \ - DEVICE_LOG(::chromeos::device_event_log::LOG_TYPE_POWER, \ - ::chromeos::device_event_log::LOG_LEVEL_##level) -#define LOGIN_LOG(level) \ - DEVICE_LOG(::chromeos::device_event_log::LOG_TYPE_LOGIN, \ - ::chromeos::device_event_log::LOG_LEVEL_##level) +#define NET_LOG(level) \ + DEVICE_LOG(::device_event_log::LOG_TYPE_NETWORK, \ + ::device_event_log::LOG_LEVEL_##level) +#define POWER_LOG(level) \ + DEVICE_LOG(::device_event_log::LOG_TYPE_POWER, \ + ::device_event_log::LOG_LEVEL_##level) +#define LOGIN_LOG(level) \ + DEVICE_LOG(::device_event_log::LOG_TYPE_LOGIN, \ + ::device_event_log::LOG_LEVEL_##level) // Generally prefer the above macros unless |type| or |level| is not constant. -#define DEVICE_LOG(type, level) \ - ::chromeos::device_event_log::internal::DeviceEventLogInstance( \ - __FILE__, __LINE__, type, level).stream() +#define DEVICE_LOG(type, level) \ + ::device_event_log::internal::DeviceEventLogInstance(__FILE__, __LINE__, \ + type, level).stream() // Declare {Type_LOG_IF_SLOW() at the top of a method to log slow methods // where "slow" is defined by kSlowMethodThresholdMs in the .cc file. #define SCOPED_NET_LOG_IF_SLOW() \ - SCOPED_DEVICE_LOG_IF_SLOW(::chromeos::device_event_log::LOG_TYPE_NETWORK) + SCOPED_DEVICE_LOG_IF_SLOW(::device_event_log::LOG_TYPE_NETWORK) // Generally prefer the above macros unless |type| is not constant. -#define SCOPED_DEVICE_LOG_IF_SLOW(type) \ - ::chromeos::device_event_log::internal::ScopedDeviceLogIfSlow \ +#define SCOPED_DEVICE_LOG_IF_SLOW(type) \ + ::device_event_log::internal::ScopedDeviceLogIfSlow \ scoped_device_log_if_slow(type, __FILE__, __func__) namespace device_event_log { @@ -82,26 +80,27 @@ enum StringOrder { OLDEST_FIRST, NEWEST_FIRST }; // Initializes / shuts down device event logging. If |max_entries| = 0 the // default value will be used. -CHROMEOS_EXPORT void Initialize(size_t max_entries); -CHROMEOS_EXPORT void Shutdown(); +DEVICE_EVENT_LOG_EXPORT void Initialize(size_t max_entries); +DEVICE_EVENT_LOG_EXPORT void Shutdown(); // If the global instance is initialized, adds an entry to it. Regardless of // whether the global instance was intitialzed, this logs the event to // LOG(ERROR) if |type| = ERROR or VLOG(1) otherwise. -CHROMEOS_EXPORT void AddEntry(const char* file, - int line, - LogType type, - LogLevel level, - const std::string& event); +DEVICE_EVENT_LOG_EXPORT void AddEntry(const char* file, + int line, + LogType type, + LogLevel level, + const std::string& event); // For backwards compatibility with network_event_log. Combines |event| and // |description| and calls AddEntry(). -CHROMEOS_EXPORT void AddEntryWithDescription(const char* file, - int line, - LogType type, - LogLevel level, - const std::string& event, - const std::string& description); +DEVICE_EVENT_LOG_EXPORT void AddEntryWithDescription( + const char* file, + int line, + LogType type, + LogLevel level, + const std::string& event, + const std::string& description); // Outputs the log to a formatted string. // |order| determines which order to output the events. @@ -119,20 +118,20 @@ CHROMEOS_EXPORT void AddEntryWithDescription(const char* file, // |max_level| determines the maximum log level to be included in the output. // |max_events| limits how many events are output if > 0, otherwise all events // are included. -CHROMEOS_EXPORT std::string GetAsString(StringOrder order, - const std::string& format, - const std::string& types, - LogLevel max_level, - size_t max_events); +DEVICE_EVENT_LOG_EXPORT std::string GetAsString(StringOrder order, + const std::string& format, + const std::string& types, + LogLevel max_level, + size_t max_events); -CHROMEOS_EXPORT extern const LogLevel kDefaultLogLevel; +DEVICE_EVENT_LOG_EXPORT extern const LogLevel kDefaultLogLevel; namespace internal { // Implementation class for DEVICE_LOG macros. Provides a stream for creating // a log string and adds the event using device_event_log::AddEntry on // destruction. -class CHROMEOS_EXPORT DeviceEventLogInstance { +class DEVICE_EVENT_LOG_EXPORT DeviceEventLogInstance { public: DeviceEventLogInstance(const char* file, int line, @@ -155,7 +154,7 @@ class CHROMEOS_EXPORT DeviceEventLogInstance { // Implementation class for SCOPED_LOG_IF_SLOW macros. Tests the elapsed time on // destruction and adds a Debug or Error log entry if it exceeds the // corresponding expected maximum elapsed time. -class CHROMEOS_EXPORT ScopedDeviceLogIfSlow { +class DEVICE_EVENT_LOG_EXPORT ScopedDeviceLogIfSlow { public: ScopedDeviceLogIfSlow(LogType type, const char* file, @@ -173,6 +172,4 @@ class CHROMEOS_EXPORT ScopedDeviceLogIfSlow { } // namespace device_event_log -} // namespace chromeos - -#endif // CHROMEOS_DEVICE_EVENT_LOG_H_ +#endif // DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_H_ diff --git a/components/device_event_log/device_event_log_export.h b/components/device_event_log/device_event_log_export.h new file mode 100644 index 0000000..fda2016 --- /dev/null +++ b/components/device_event_log/device_event_log_export.h @@ -0,0 +1,29 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_EXPORT_H_ +#define COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_EXPORT_H_ + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(DEVICE_EVENT_LOG_IMPLEMENTATION) +#define DEVICE_EVENT_LOG_EXPORT __declspec(dllexport) +#else +#define DEVICE_EVENT_LOG_EXPORT __declspec(dllimport) +#endif // defined(DEVICE_EVENT_LOG_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(DEVICE_EVENT_LOG_IMPLEMENTATION) +#define DEVICE_EVENT_LOG_EXPORT __attribute__((visibility("default"))) +#else +#define DEVICE_EVENT_LOG_EXPORT +#endif +#endif + +#else // defined(COMPONENT_BUILD) +#define DEVICE_EVENT_LOG_EXPORT +#endif + +#endif // COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_EXPORT_H_ diff --git a/chromeos/device_event_log_impl.cc b/components/device_event_log/device_event_log_impl.cc index 8df670b..b260991 100644 --- a/chromeos/device_event_log_impl.cc +++ b/components/device_event_log/device_event_log_impl.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/device_event_log_impl.h" +#include "components/device_event_log/device_event_log_impl.h" #include <cmath> #include <list> #include <set> -#include "base/files/file_path.h" +#include "base/containers/adapters.h" #include "base/json/json_string_value_serializer.h" #include "base/json/json_writer.h" #include "base/logging.h" @@ -20,8 +20,6 @@ #include "base/values.h" #include "net/base/escape.h" -namespace chromeos { - namespace device_event_log { namespace { @@ -325,32 +323,30 @@ std::string DeviceEventLogImpl::GetAsString(StringOrder order, // determine the first entry to include. size_t shown_events = 0; size_t num_entries = 0; - for (LogEntryList::const_reverse_iterator riter = entries_.rbegin(); - riter != entries_.rend(); ++riter) { + for (const LogEntry& entry : base::Reversed(entries_)) { ++num_entries; - if (!LogEntryMatchesTypes(*riter, include_types, exclude_types)) + if (!LogEntryMatchesTypes(entry, include_types, exclude_types)) continue; - if (riter->log_level > max_level) + if (entry.log_level > max_level) continue; if (++shown_events >= max_events) break; } offset = entries_.size() - num_entries; } - for (LogEntryList::const_iterator iter = entries_.begin(); - iter != entries_.end(); ++iter) { + for (const LogEntry& entry : entries_) { if (offset > 0) { --offset; continue; } - if (!LogEntryMatchesTypes(*iter, include_types, exclude_types)) + if (!LogEntryMatchesTypes(entry, include_types, exclude_types)) continue; - if (iter->log_level > max_level) + if (entry.log_level > max_level) continue; if (format_json) { - log_entries.AppendString(LogEntryAsJSON(*iter)); + log_entries.AppendString(LogEntryAsJSON(entry)); } else { - result += LogEntryToString(*iter, show_time, show_file, show_type, + result += LogEntryToString(entry, show_time, show_file, show_type, show_level, format_html); result += "\n"; } @@ -358,16 +354,15 @@ std::string DeviceEventLogImpl::GetAsString(StringOrder order, } else { size_t nlines = 0; // Iterate backwards through the list to show the most recent entries first. - for (LogEntryList::const_reverse_iterator riter = entries_.rbegin(); - riter != entries_.rend(); ++riter) { - if (!LogEntryMatchesTypes(*riter, include_types, exclude_types)) + for (const LogEntry& entry : base::Reversed(entries_)) { + if (!LogEntryMatchesTypes(entry, include_types, exclude_types)) continue; - if (riter->log_level > max_level) + if (entry.log_level > max_level) continue; if (format_json) { - log_entries.AppendString(LogEntryAsJSON(*riter)); + log_entries.AppendString(LogEntryAsJSON(entry)); } else { - result += LogEntryToString(*riter, show_time, show_file, show_type, + result += LogEntryToString(entry, show_time, show_file, show_type, show_level, format_html); result += "\n"; } @@ -394,10 +389,13 @@ DeviceEventLogImpl::LogEntry::LogEntry(const char* filedesc, event(event), time(base::Time::Now()), count(1) { - if (filedesc) - file = base::FilePath(std::string(filedesc)).BaseName().value(); + if (filedesc) { + file = filedesc; + size_t last_slash_pos = file.find_last_of("\\/"); + if (last_slash_pos != std::string::npos) { + file.erase(0, last_slash_pos + 1); + } + } } } // namespace device_event_log - -} // namespace chromeos diff --git a/chromeos/device_event_log_impl.h b/components/device_event_log/device_event_log_impl.h index f18bff5..8b7e11a 100644 --- a/chromeos/device_event_log_impl.h +++ b/components/device_event_log/device_event_log_impl.h @@ -2,21 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_ -#define CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_ +#ifndef COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_ +#define COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_ #include <list> #include <string> #include "base/time/time.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/device_event_log.h" - -namespace chromeos { +#include "components/device_event_log/device_event_log.h" +#include "components/device_event_log/device_event_log_export.h" namespace device_event_log { -class CHROMEOS_EXPORT DeviceEventLogImpl { +class DEVICE_EVENT_LOG_EXPORT DeviceEventLogImpl { public: struct LogEntry { LogEntry(const char* filedesc, @@ -78,6 +76,4 @@ class CHROMEOS_EXPORT DeviceEventLogImpl { } // namespace device_event_log -} // namespace chromeos - -#endif // CHROMEOS_DEVICE_EVENT_LOG_IMPL_H_ +#endif // COMPONENTS_DEVICE_EVENT_LOG_DEVICE_EVENT_LOG_IMPL_H_ diff --git a/chromeos/device_event_log_impl_unittest.cc b/components/device_event_log/device_event_log_impl_unittest.cc index 7c9e8c9..b6eff23 100644 --- a/chromeos/device_event_log_impl_unittest.cc +++ b/components/device_event_log/device_event_log_impl_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/device_event_log_impl.h" +#include "components/device_event_log/device_event_log_impl.h" #include <algorithm> @@ -14,8 +14,6 @@ #include "base/strings/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { - namespace device_event_log { namespace { @@ -261,5 +259,3 @@ TEST_F(DeviceEventLogTest, TestType) { } } // namespace device_event_log - -} // namespace chromeos diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index d987737..0f28828 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -123,6 +123,7 @@ 'dependencies': [ '../base/base.gyp:base', '../base/base.gyp:base_prefs', + '../components/components.gyp:device_event_log_component', '../components/components.gyp:keyed_service_content', '../components/components.gyp:keyed_service_core', '../components/components.gyp:onc_component', diff --git a/ui/chromeos/DEPS b/ui/chromeos/DEPS index e89a792..c533fe6 100644 --- a/ui/chromeos/DEPS +++ b/ui/chromeos/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+chromeos", + "+components/device_event_log", "+grit/ui_chromeos_resources.h", "+grit/ui_chromeos_strings.h", "+third_party/cros_system_api", diff --git a/ui/chromeos/network/network_list.cc b/ui/chromeos/network/network_list.cc index fb807e5..1fff907 100644 --- a/ui/chromeos/network/network_list.cc +++ b/ui/chromeos/network/network_list.cc @@ -7,10 +7,10 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" #include "chromeos/dbus/power_manager_client.h" -#include "chromeos/device_event_log.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler_observer.h" +#include "components/device_event_log/device_event_log.h" #include "grit/ui_chromeos_strings.h" #include "ui/base/resource/resource_bundle.h" #include "ui/chromeos/network/network_icon.h" diff --git a/ui/chromeos/ui_chromeos.gyp b/ui/chromeos/ui_chromeos.gyp index 1b7ee6c..f55823e 100644 --- a/ui/chromeos/ui_chromeos.gyp +++ b/ui/chromeos/ui_chromeos.gyp @@ -49,6 +49,7 @@ '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../../chromeos/chromeos.gyp:chromeos', '../../chromeos/chromeos.gyp:power_manager_proto', + '../../components/components.gyp:device_event_log_component', '../../skia/skia.gyp:skia', '../aura/aura.gyp:aura', '../base/ime/ui_base_ime.gyp:ui_base_ime', |