| 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 fe016f79c6553fb37908b82b5ec18214fa12bcbf..48932119972443b6ea9d8077bd6df463114ba697 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"
|
| @@ -79,6 +78,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()));
|
| }
|
|
|