| Index: chrome/browser/ui/webui/net_internals/net_internals_ui.cc
|
| 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 45ed8af9c70d21d4c9e697bea24b8b56dc706661..4762a24db67b3dda6a12db23c516f2b3edcfa317 100644
|
| --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
|
| +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
|
| @@ -44,7 +44,6 @@
|
| #include "chrome/browser/ui/webui/extensions/extension_basic_info.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 "components/onc/onc_constants.h"
|
| @@ -83,6 +82,7 @@
|
| #include "chrome/browser/chromeos/login/users/user_manager.h"
|
| #include "chrome/browser/chromeos/net/onc_utils.h"
|
| #include "chrome/browser/chromeos/system/syslogs_provider.h"
|
| +#include "chrome/browser/chromeos/system_logs/debug_log_writer.h"
|
| #include "chrome/browser/net/nss_context.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| #include "chromeos/dbus/debug_daemon_client.h"
|
| @@ -207,77 +207,6 @@ content::WebUIDataSource* CreateNetInternalsHTMLSource() {
|
| return source;
|
| }
|
|
|
| -#if defined(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 base::FilePath& log_path,
|
| - bool succeded)> StoreDebugLogsCallback;
|
| -
|
| -// Called upon completion of |WriteDebugLogToFile|. Closes file
|
| -// descriptor, deletes log file in the case of failure and calls
|
| -// |callback|.
|
| -void WriteDebugLogToFileCompleted(const StoreDebugLogsCallback& callback,
|
| - const base::FilePath& file_path,
|
| - bool succeeded) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - if (!succeeded) {
|
| - bool posted = BrowserThread::PostBlockingPoolTaskAndReply(
|
| - FROM_HERE,
|
| - base::Bind(base::IgnoreResult(&base::DeleteFile), file_path, false),
|
| - base::Bind(callback, file_path, false));
|
| - DCHECK(posted);
|
| - return;
|
| - }
|
| - callback.Run(file_path, true);
|
| -}
|
| -
|
| -// Stores into |file_path| debug logs in the .tgz format. Calls
|
| -// |callback| upon completion.
|
| -void WriteDebugLogToFile(const StoreDebugLogsCallback& callback,
|
| - base::File* file,
|
| - const base::FilePath& file_path) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - if (!file->IsValid()) {
|
| - LOG(ERROR) <<
|
| - "Can't create debug log file: " << file_path.AsUTF8Unsafe() << ", " <<
|
| - "error: " << file->error_details();
|
| - return;
|
| - }
|
| - chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->GetDebugLogs(
|
| - file->Pass(),
|
| - base::Bind(&WriteDebugLogToFileCompleted, callback, file_path));
|
| -}
|
| -
|
| -// Stores debug logs in the .tgz archive on the |fileshelf|. The file
|
| -// is created on the worker pool, then writing to it is triggered from
|
| -// the UI thread, and finally it is closed (on success) or deleted (on
|
| -// failure) on the worker pool, prior to calling |callback|.
|
| -void StoreDebugLogs(const base::FilePath& fileshelf,
|
| - const StoreDebugLogsCallback& callback) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - DCHECK(!callback.is_null());
|
| -
|
| - const base::FilePath::CharType kLogFileName[] =
|
| - FILE_PATH_LITERAL("debug-log.tgz");
|
| -
|
| - base::FilePath file_path = fileshelf.Append(kLogFileName);
|
| - file_path = logging::GenerateTimestampedName(file_path, base::Time::Now());
|
| -
|
| - int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE;
|
| - base::File* file = new base::File;
|
| - bool posted = BrowserThread::PostBlockingPoolTaskAndReply(
|
| - FROM_HERE,
|
| - base::Bind(&base::File::Initialize,
|
| - base::Unretained(file), file_path, flags),
|
| - base::Bind(&WriteDebugLogToFile, callback, base::Owned(file), file_path));
|
| - DCHECK(posted);
|
| -}
|
| -#endif // defined(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.
|
| @@ -1534,7 +1463,7 @@ void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) {
|
| new base::StringValue("Creating log file..."));
|
| const DownloadPrefs* const prefs =
|
| DownloadPrefs::FromBrowserContext(Profile::FromWebUI(web_ui()));
|
| - StoreDebugLogs(prefs->DownloadPath(),
|
| + chromeos::DebugLogWriter::StoreLogs(prefs->DownloadPath(),
|
| base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted,
|
| AsWeakPtr()));
|
| }
|
|
|