diff options
-rw-r--r-- | chrome/browser/resources/net_internals/browser_bridge.js | 20 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/chromeos_view.html | 9 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/chromeos_view.js | 21 | ||||
-rw-r--r-- | chrome/browser/ui/webui/net_internals/net_internals_ui.cc | 111 | ||||
-rw-r--r-- | chrome/common/logging_chrome.cc | 28 | ||||
-rw-r--r-- | chrome/common/logging_chrome.h | 5 | ||||
-rw-r--r-- | chromeos/dbus/debug_daemon_client.cc | 30 | ||||
-rw-r--r-- | chromeos/dbus/debug_daemon_client.h | 10 | ||||
-rw-r--r-- | chromeos/dbus/mock_debug_daemon_client.h | 2 |
9 files changed, 15 insertions, 221 deletions
diff --git a/chrome/browser/resources/net_internals/browser_bridge.js b/chrome/browser/resources/net_internals/browser_bridge.js index 5184f3a..7353b45 100644 --- a/chrome/browser/resources/net_internals/browser_bridge.js +++ b/chrome/browser/resources/net_internals/browser_bridge.js @@ -26,7 +26,6 @@ var BrowserBridge = (function() { this.httpThrottlingObservers_ = []; this.constantsObservers_ = []; this.crosONCFileParseObservers_ = []; - this.storeDebugLogsObservers_ = []; this.pollableDataHelpers_ = {}; this.pollableDataHelpers_.proxySettings = @@ -234,10 +233,6 @@ var BrowserBridge = (function() { this.send('importONCFile', [fileContent, passcode]); }, - storeDebugLogs: function() { - this.send('storeDebugLogs'); - }, - sendGetHttpPipeliningStatus: function() { this.send('getHttpPipeliningStatus'); }, @@ -330,11 +325,6 @@ var BrowserBridge = (function() { this.crosONCFileParseObservers_[i].onONCFileParse(error); }, - receivedStoreDebugLogs: function(status) { - for (var i = 0; i < this.storeDebugLogsObservers_.length; i++) - this.storeDebugLogsObservers_[i].onStoreDebugLogs(status); - }, - receivedHttpCacheInfo: function(info) { this.pollableDataHelpers_.httpCacheInfo.update(info); }, @@ -531,16 +521,6 @@ var BrowserBridge = (function() { }, /** - * Adds a listener for storing log file status. The observer will be called - * back with: - * - * observer.onStoreDebugLogs(status); - */ - addStoreDebugLogsObserver: function(observer) { - this.storeDebugLogsObservers_.push(observer); - }, - - /** * Adds a listener for HTTP throttling-related events. |observer| will be * called back when HTTP throttling is enabled/disabled, through: * diff --git a/chrome/browser/resources/net_internals/chromeos_view.html b/chrome/browser/resources/net_internals/chromeos_view.html index 098b04f..6b552ae 100644 --- a/chrome/browser/resources/net_internals/chromeos_view.html +++ b/chrome/browser/resources/net_internals/chromeos_view.html @@ -11,13 +11,4 @@ </div> <div id="chromeos-view-parse-status" hidden> </div> - <div id="chromeos-view-store-debug-logs-div"> - <h3>Store Logs</h3> - <input type="button" - id="chromeos-view-store-debug-logs" - value="Store Debug Logs"> - <label for="chromeos-view-store-debug-logs" - id="chromeos-view-store-debug-logs-status"> - </label> - </div> </div> diff --git a/chrome/browser/resources/net_internals/chromeos_view.js b/chrome/browser/resources/net_internals/chromeos_view.js index 61955ab..fea3e36 100644 --- a/chrome/browser/resources/net_internals/chromeos_view.js +++ b/chrome/browser/resources/net_internals/chromeos_view.js @@ -125,17 +125,7 @@ var CrosView = (function() { } /** - * Set storing debug logs status. - * - * @private - */ - function setStoreDebugLogsStatus_(status) { - $(CrosView.STORE_DEBUG_LOGS_STATUS_ID).innerText = status; - } - - /** - * Add event listeners for the file selection, passcode input - * fields and for the button for debug logs storing. + * Add event listeners for the file selection and passcode input fields. * * @private */ @@ -147,11 +137,6 @@ var CrosView = (function() { $(CrosView.PASSCODE_INPUT_ID).addEventListener('change', function(event) { setPasscode_(this.value); }, false); - - $(CrosView.STORE_DEBUG_LOGS_ID).addEventListener('click', function(event) { - $(CrosView.STORE_DEBUG_LOGS_STATUS_ID).innerText = ''; - g_browser.storeDebugLogs(); - }, false); } /** @@ -176,7 +161,6 @@ var CrosView = (function() { DivView.call(this, CrosView.MAIN_BOX_ID); g_browser.addCrosONCFileParseObserver(this); - g_browser.addStoreDebugLogsObserver(this); addEventListeners_(); } @@ -189,8 +173,6 @@ var CrosView = (function() { CrosView.PASSCODE_ID = 'chromeos-view-password-div'; CrosView.PASSCODE_INPUT_ID = 'chromeos-view-onc-password'; CrosView.PARSE_STATUS_ID = 'chromeos-view-parse-status'; - CrosView.STORE_DEBUG_LOGS_ID = 'chromeos-view-store-debug-logs'; - CrosView.STORE_DEBUG_LOGS_STATUS_ID = 'chromeos-view-store-debug-logs-status'; cr.addSingletonGetter(CrosView); @@ -199,7 +181,6 @@ var CrosView = (function() { __proto__: DivView.prototype, onONCFileParse: setParseStatus_, - onStoreDebugLogs: setStoreDebugLogsStatus_, }; return CrosView; diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc index dc77e63..4d77bf8 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc @@ -14,14 +14,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" -#include "base/file_path.h" -#include "base/file_util.h" #include "base/memory/singleton.h" -#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/message_loop_helpers.h" #include "base/path_service.h" -#include "base/platform_file.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" #include "base/string_split.h" @@ -43,7 +39,6 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_version_info.h" -#include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" @@ -77,15 +72,11 @@ #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/system/syslogs_provider.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/debug_daemon_client.h" #endif #ifdef OS_WIN #include "chrome/browser/net/service_providers_win.h" #endif -using base::PlatformFile; -using base::PlatformFileError; using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; @@ -157,84 +148,6 @@ ChromeWebUIDataSource* CreateNetInternalsHTMLSource() { return source; } -#ifdef OS_CHROMEOS -// Following functions are used for getting debug logs. Logs are -// fetched from /var/log/* and put on the fileshelf. - -// Called once StoreDebugLogs is complete. Takes two parameters: -// - log_path: where the log file was saved in the case of success; -// - succeeded: was the log file saved successfully. -typedef base::Callback<void(const FilePath& log_path, - bool succeded)> StoreDebugLogsCallback; - -// Called once creation of the debug log file is completed. If -// creation failed, deletes the file by |log_path|. So, this function -// should be called on the FILE thread. After all, calls |callback| on -// the UI thread. -void CreateDebugLogFileCompleted(const StoreDebugLogsCallback& callback, - const FilePath& log_path, - bool succeeded) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - - if (!succeeded) - file_util::Delete(log_path, false); - - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(callback, log_path, succeeded)); -} - -// Retrieves debug logs from DebugDaemon and puts them on the -// fileshelf directory into .tgz archive. So, this function should be -// called on the FILE thread. Calls CreateDebugLogFileCompleted on the -// FILE thread when creation of archive is completed. -void CreateDebugLogFile(const StoreDebugLogsCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - - const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("debug-log.tgz"); - - FilePath fileshelf_dir; - if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &fileshelf_dir)) { - LOG(ERROR) << "Can't get fileshelf dir"; - CreateDebugLogFileCompleted(callback, FilePath(), false); - return; - } - - FilePath log_path = fileshelf_dir.Append(kLogFileName); - log_path = logging::GenerateTimestampedName(log_path, base::Time::Now()); - - int flags = base::PLATFORM_FILE_CREATE_ALWAYS | - base::PLATFORM_FILE_WRITE; - bool created; - PlatformFileError error; - PlatformFile log_file = base::CreatePlatformFile( - log_path, flags, &created, &error); - - if (!created) { - LOG(ERROR) << - "Can't create log file: " << log_path.AsUTF8Unsafe() << ", " << - "error: " << error; - CreateDebugLogFileCompleted(callback, log_path, false); - return; - } - chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()-> - GetDebugLogs(log_file, - base::Bind(&CreateDebugLogFileCompleted, - callback, log_path)); -} - -// Delegates the job of saving debug logs on the fileshelf to -// CreateDebugLogsFile on the FILE thread. Calls |callback| on the UI -// thread when saving is completed. This function should be called on -// the UI thread. -void StoreDebugLogs(const StoreDebugLogsCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, - base::Bind(&CreateDebugLogFile, callback)); -} -#endif // OS_CHROMEOS - // This class receives javascript messages from the renderer. // Note that the WebUI infrastructure runs on the UI thread, therefore all of // this class's methods are expected to run on the UI thread. @@ -274,8 +187,6 @@ class NetInternalsMessageHandler void OnRefreshSystemLogs(const ListValue* list); void OnGetSystemLog(const ListValue* list); void OnImportONCFile(const ListValue* list); - void OnStoreDebugLogs(const ListValue* list); - void OnStoreDebugLogsCompleted(const FilePath& log_path, bool succeeded); #endif private: @@ -645,10 +556,6 @@ void NetInternalsMessageHandler::RegisterMessages() { "importONCFile", base::Bind(&NetInternalsMessageHandler::OnImportONCFile, base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "storeDebugLogs", - base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogs, - base::Unretained(this))); #endif } @@ -1361,24 +1268,6 @@ void NetInternalsMessageHandler::OnImportONCFile(const ListValue* list) { SendJavascriptCommand("receivedONCFileParse", Value::CreateStringValue(error)); } - -void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { - StoreDebugLogs( - base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, - AsWeakPtr())); -} - -void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( - const FilePath& log_path, bool succeeded) { - std::string status; - if (succeeded) - status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); - else - status = "Failed to create log file"; - SendJavascriptCommand("receivedStoreDebugLogs", - Value::CreateStringValue(status)); -} - #endif void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 5ad8482..6dfab83 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -164,6 +164,20 @@ LoggingDestination DetermineLogMode(const CommandLine& command_line) { #if defined(OS_CHROMEOS) namespace { +FilePath GenerateTimestampedName(const FilePath& base_path, + base::Time timestamp) { + base::Time::Exploded time_deets; + timestamp.LocalExplode(&time_deets); + std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", + time_deets.year, + time_deets.month, + time_deets.day_of_month, + time_deets.hour, + time_deets.minute, + time_deets.second); + return base_path.InsertBeforeExtension(suffix); +} + FilePath SetUpSymlinkIfNeeded(const FilePath& symlink_path, bool new_log) { DCHECK(!symlink_path.empty()); @@ -458,18 +472,4 @@ void SetDumpWithoutCrashingFunction(void (*function)()) { } #endif -FilePath GenerateTimestampedName(const FilePath& base_path, - base::Time timestamp) { - base::Time::Exploded time_deets; - timestamp.LocalExplode(&time_deets); - std::string suffix = base::StringPrintf("_%02d%02d%02d-%02d%02d%02d", - time_deets.year, - time_deets.month, - time_deets.day_of_month, - time_deets.hour, - time_deets.minute, - time_deets.second); - return base_path.InsertBeforeExtensionASCII(suffix); -} - } // namespace logging diff --git a/chrome/common/logging_chrome.h b/chrome/common/logging_chrome.h index c2079a2..a448c3d 100644 --- a/chrome/common/logging_chrome.h +++ b/chrome/common/logging_chrome.h @@ -10,7 +10,6 @@ #include <vector> #include "base/logging.h" -#include "base/time.h" class CommandLine; class FilePath; @@ -72,10 +71,6 @@ void DumpWithoutCrashing(); void SetDumpWithoutCrashingFunction(void (*function)()); #endif -// Inserts timestamp before file extension in the format -// "_yymmdd-hhmmss". -FilePath GenerateTimestampedName(const FilePath& base_path, - base::Time timestamp); } // namespace logging #endif // CHROME_COMMON_LOGGING_CHROME_H_ diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc index 50d9334..bc8e06d 100644 --- a/chromeos/dbus/debug_daemon_client.cc +++ b/chromeos/dbus/debug_daemon_client.cc @@ -150,22 +150,6 @@ class DebugDaemonClientImpl : public DebugDaemonClient { virtual ~DebugDaemonClientImpl() {} // DebugDaemonClient override. - virtual void GetDebugLogs(base::PlatformFile file, - const GetDebugLogsCallback& callback) OVERRIDE { - dbus::MethodCall method_call( - debugd::kDebugdInterface, - debugd::kGetDebugLogs); - dbus::MessageWriter writer(&method_call); - writer.AppendFileDescriptor(dbus::FileDescriptor(file)); - - debugdaemon_proxy_->CallMethod( - &method_call, - dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, - base::Bind(&DebugDaemonClientImpl::OnGetDebugLogs, - weak_ptr_factory_.GetWeakPtr(), - callback)); - } - virtual void StartSystemTracing() OVERRIDE { dbus::MethodCall method_call( debugd::kDebugdInterface, @@ -225,16 +209,6 @@ class DebugDaemonClientImpl : public DebugDaemonClient { } private: - void OnGetDebugLogs(const GetDebugLogsCallback& callback, - dbus::Response* response) { - if (!response) { - LOG(ERROR) << "Failed to get debug logs"; - callback.Run(false); - return; - } - callback.Run(true); - } - // Called when a response for StartSystemTracing() is received. void OnStartSystemTracing(dbus::Response* response) { if (!response) { @@ -270,10 +244,6 @@ class DebugDaemonClientImpl : public DebugDaemonClient { // which does nothing. class DebugDaemonClientStubImpl : public DebugDaemonClient { // DebugDaemonClient overrides. - virtual void GetDebugLogs(base::PlatformFile file, - const GetDebugLogsCallback& callback) OVERRIDE { - callback.Run(false); - } virtual void StartSystemTracing() OVERRIDE {} virtual bool RequestStopSystemTracing(const StopSystemTracingCallback& callback) OVERRIDE { diff --git a/chromeos/dbus/debug_daemon_client.h b/chromeos/dbus/debug_daemon_client.h index cc91a94..38e4015 100644 --- a/chromeos/dbus/debug_daemon_client.h +++ b/chromeos/dbus/debug_daemon_client.h @@ -6,7 +6,6 @@ #define CHROMEOS_DBUS_DEBUG_DAEMON_CLIENT_H_ #include "base/callback.h" -#include "base/platform_file.h" #include "base/memory/ref_counted_memory.h" #include "chromeos/chromeos_export.h" #include "chromeos/dbus/dbus_client_implementation_type.h" @@ -22,15 +21,6 @@ class CHROMEOS_EXPORT DebugDaemonClient { public: virtual ~DebugDaemonClient(); - // Called once GetDebugLogs() is complete. Takes one parameter: - // - succeeded: was the logs stored successfully. - typedef base::Callback<void(bool succeeded)> GetDebugLogsCallback; - - // Requests to store debug logs into |file| and calls |callback| - // when completed. Debug logs will be stored in the .tgz format. - virtual void GetDebugLogs(base::PlatformFile file, - const GetDebugLogsCallback& callback) = 0; - // Requests to start system/kernel tracing. virtual void StartSystemTracing() = 0; diff --git a/chromeos/dbus/mock_debug_daemon_client.h b/chromeos/dbus/mock_debug_daemon_client.h index f55b98f6..05f553f 100644 --- a/chromeos/dbus/mock_debug_daemon_client.h +++ b/chromeos/dbus/mock_debug_daemon_client.h @@ -15,8 +15,6 @@ class MockDebugDaemonClient : public DebugDaemonClient { MockDebugDaemonClient(); virtual ~MockDebugDaemonClient(); - MOCK_METHOD2(GetDebugLogs, void(base::PlatformFile, - const GetDebugLogsCallback&)); MOCK_METHOD1(RequestStopSystemTracing, bool(const StopSystemTracingCallback&)); MOCK_METHOD0(StartSystemTracing, void()); |