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 2224337c0ff2b4b8a113e0be978a5674014eab09..151870b781187926a73d8db7db7648fb6aafdf47 100644 |
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
@@ -42,7 +42,6 @@ |
#include "chrome/browser/profiles/profile.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" |
@@ -78,6 +77,7 @@ |
#include "chrome/browser/chromeos/net/onc_utils.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.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" |
@@ -212,78 +212,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(); |
- callback.Run(file_path, false); |
- 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. |
@@ -1537,12 +1465,14 @@ void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { |
SendJavascriptCommand("receivedStoreDebugLogs", |
new base::StringValue("Creating log file...")); |
- Profile* const profile = Profile::FromWebUI(web_ui()); |
+ Profile* profile = Profile::FromWebUI(web_ui()); |
const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); |
base::FilePath path = prefs->DownloadPath(); |
if (file_manager::util::IsUnderNonNativeLocalPath(profile, path)) |
path = prefs->GetDefaultDownloadDirectoryForProfile(); |
- StoreDebugLogs(path, |
+ chromeos::DebugLogWriter::StoreLogs( |
+ path, |
+ true, // should_compress |
base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
AsWeakPtr())); |
} |