summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 14:33:11 +0000
committerygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 14:33:11 +0000
commit02ad2f17cedc32809da4f9807ef0048952304e9f (patch)
treea7e302d472d100f01dbb37d957752dc1285518c2
parent550d1e5dd1d83e31730ec7cb55d41b9614ea0397 (diff)
downloadchromium_src-02ad2f17cedc32809da4f9807ef0048952304e9f.zip
chromium_src-02ad2f17cedc32809da4f9807ef0048952304e9f.tar.gz
chromium_src-02ad2f17cedc32809da4f9807ef0048952304e9f.tar.bz2
Refactored StoreDebugLogs() path.
WorkerPool is replaced by BlockingPool in DebugDaemonClient. Added test for chrome://net-internals#chromeos "Store Debug Logs" button. Based on https://codereview.chromium.org/323533002/. BUG=387749 TEST=browser_tests:NetInternalsTest.netInternalsChromeOSViewStoreDebugLogs Review URL: https://codereview.chromium.org/407783003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285902 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/system_logs/debug_log_writer.cc3
-rw-r--r--chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc3
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/data/webui/net_internals/chromeos_view.js64
-rw-r--r--chromeos/dbus/debug_daemon_client.cc15
-rw-r--r--chromeos/dbus/debug_daemon_client.h7
-rw-r--r--chromeos/dbus/fake_debug_daemon_client.cc4
-rw-r--r--chromeos/dbus/fake_debug_daemon_client.h2
-rw-r--r--content/browser/tracing/tracing_controller_impl.cc12
9 files changed, 94 insertions, 17 deletions
diff --git a/chrome/browser/chromeos/system_logs/debug_log_writer.cc b/chrome/browser/chromeos/system_logs/debug_log_writer.cc
index 92b7d63..bf38531 100644
--- a/chrome/browser/chromeos/system_logs/debug_log_writer.cc
+++ b/chrome/browser/chromeos/system_logs/debug_log_writer.cc
@@ -71,9 +71,12 @@ void WriteDebugLogToFile(base::File* file,
<< "error: " << file->error_details();
return;
}
+ scoped_refptr<base::TaskRunner> task_runner =
+ GetSequencedTaskRunner(sequence_token_name);
chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->DumpDebugLogs(
should_compress,
file->Pass(),
+ task_runner,
base::Bind(&WriteDebugLogToFileCompleted,
file_path,
sequence_token_name,
diff --git a/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc b/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc
index 85db29e..ca6b24f 100644
--- a/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc
@@ -32,9 +32,10 @@ class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient {
virtual void DumpDebugLogs(bool is_compressed,
base::File file,
+ scoped_refptr<base::TaskRunner> task_runner,
const GetDebugLogsCallback& callback) OVERRIDE {
base::File* file_param = new base::File(file.Pass());
- content::BrowserThread::PostBlockingPoolTaskAndReply(
+ task_runner->PostTaskAndReply(
FROM_HERE,
base::Bind(
&GenerateTestLogDumpFile, test_file_, base::Owned(file_param)),
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index c950057..0d78e34 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1571,6 +1571,7 @@
'test/data/webui/history_ui_browsertest.h',
'test/data/webui/mock4js_browsertest.js',
'test/data/webui/net_internals/bandwidth_view.js',
+ 'test/data/webui/net_internals/chromeos_view.js',
'test/data/webui/net_internals/dns_view.js',
'test/data/webui/net_internals/events_view.js',
'test/data/webui/net_internals/hsts_view.js',
diff --git a/chrome/test/data/webui/net_internals/chromeos_view.js b/chrome/test/data/webui/net_internals/chromeos_view.js
new file mode 100644
index 0000000..a2ffb9f
--- /dev/null
+++ b/chrome/test/data/webui/net_internals/chromeos_view.js
@@ -0,0 +1,64 @@
+// Copyright 2014 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.
+
+// Include test fixture.
+GEN_INCLUDE(['net_internals_test.js']);
+
+// Anonymous namespace
+(function() {
+
+function DebugLogsStatusWatcher() {
+ NetInternalsTest.Task.call(this);
+ this.setCompleteAsync(true);
+}
+
+DebugLogsStatusWatcher.prototype = {
+ __proto__: NetInternalsTest.Task.prototype,
+
+ start: function() {
+ g_browser.addStoreDebugLogsObserver(this);
+ $('chromeos-view-store-debug-logs').click();
+ },
+
+ onStoreDebugLogs: function(status) {
+ if (status.indexOf('Created') != -1) {
+ this.onTaskDone(true);
+ return;
+ }
+ if (status.indexOf('Failed') != -1) {
+ this.onTaskDone(false);
+ return;
+ }
+ }
+};
+
+function ResultChecker() {
+ NetInternalsTest.Task.call(this);
+}
+
+ResultChecker.prototype = {
+ __proto__: NetInternalsTest.Task.prototype,
+
+ start: function(success) {
+ assertTrue(success);
+ this.onTaskDone();
+ }
+};
+
+TEST_F('NetInternalsTest',
+ 'netInternalsChromeOSViewStoreDebugLogs',
+ function() {
+ if (!cr.isChromeOS)
+ testDone();
+ // #chromeos-view-import-onc fails accessibility check.
+ this.runAccessibilityChecks = false;
+ NetInternalsTest.switchToView('chromeos');
+
+ var taskQueue = new NetInternalsTest.TaskQueue(true);
+ taskQueue.addTask(new DebugLogsStatusWatcher());
+ taskQueue.addTask(new ResultChecker());
+ taskQueue.run();
+});
+
+})(); // Anonymous namespace
diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc
index 432f3f7..4f60526 100644
--- a/chromeos/dbus/debug_daemon_client.cc
+++ b/chromeos/dbus/debug_daemon_client.cc
@@ -19,7 +19,6 @@
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_util.h"
#include "base/task_runner_util.h"
-#include "base/threading/worker_pool.h"
#include "chromeos/dbus/pipe_reader.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@@ -48,12 +47,13 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
// DebugDaemonClient override.
virtual void DumpDebugLogs(bool is_compressed,
base::File file,
+ scoped_refptr<base::TaskRunner> task_runner,
const GetDebugLogsCallback& callback) OVERRIDE {
dbus::FileDescriptor* file_descriptor = new dbus::FileDescriptor;
file_descriptor->PutValue(file.TakePlatformFile());
// Punt descriptor validity check to a worker thread; on return we'll
// issue the D-Bus request to stop tracing and collect results.
- base::WorkerPool::PostTaskAndReply(
+ task_runner->PostTaskAndReply(
FROM_HERE,
base::Bind(&dbus::FileDescriptor::CheckValidity,
base::Unretained(file_descriptor)),
@@ -61,8 +61,7 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
weak_ptr_factory_.GetWeakPtr(),
is_compressed,
base::Owned(file_descriptor),
- callback),
- false);
+ callback));
}
virtual void SetDebugMode(const std::string& subsystem,
@@ -217,16 +216,14 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
weak_ptr_factory_.GetWeakPtr()));
}
- virtual bool RequestStopSystemTracing(const StopSystemTracingCallback&
- callback) OVERRIDE {
+ virtual bool RequestStopSystemTracing(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const StopSystemTracingCallback& callback) OVERRIDE {
if (pipe_reader_ != NULL) {
LOG(ERROR) << "Busy doing StopSystemTracing";
return false;
}
- scoped_refptr<base::TaskRunner> task_runner =
- base::WorkerPool::GetTaskRunner(true /* task_is_slow */);
-
pipe_reader_.reset(new PipeReaderForString(
task_runner,
base::Bind(&DebugDaemonClientImpl::OnIOComplete,
diff --git a/chromeos/dbus/debug_daemon_client.h b/chromeos/dbus/debug_daemon_client.h
index 30cc5a4..36ef3b2 100644
--- a/chromeos/dbus/debug_daemon_client.h
+++ b/chromeos/dbus/debug_daemon_client.h
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/files/file.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/task_runner.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"
@@ -33,6 +34,7 @@ class CHROMEOS_EXPORT DebugDaemonClient : public DBusClient {
// |is_compressed| is true, otherwise in logs will be stored in .tar format.
virtual void DumpDebugLogs(bool is_compressed,
base::File file,
+ scoped_refptr<base::TaskRunner> task_runner,
const GetDebugLogsCallback& callback) = 0;
// Called once SetDebugMode() is complete. Takes one parameter:
@@ -116,8 +118,9 @@ class CHROMEOS_EXPORT DebugDaemonClient : public DBusClient {
result)> StopSystemTracingCallback;
// Requests to stop system tracing and calls |callback| when completed.
- virtual bool RequestStopSystemTracing(const StopSystemTracingCallback&
- callback) = 0;
+ virtual bool RequestStopSystemTracing(
+ scoped_refptr<base::TaskRunner> task_runner,
+ const StopSystemTracingCallback& callback) = 0;
// Returns an empty SystemTracingCallback that does nothing.
static StopSystemTracingCallback EmptyStopSystemTracingCallback();
diff --git a/chromeos/dbus/fake_debug_daemon_client.cc b/chromeos/dbus/fake_debug_daemon_client.cc
index 549a2c6..a1d75f6 100644
--- a/chromeos/dbus/fake_debug_daemon_client.cc
+++ b/chromeos/dbus/fake_debug_daemon_client.cc
@@ -24,8 +24,9 @@ void FakeDebugDaemonClient::Init(dbus::Bus* bus) {}
void FakeDebugDaemonClient::DumpDebugLogs(
bool is_compressed,
base::File file,
+ scoped_refptr<base::TaskRunner> task_runner,
const GetDebugLogsCallback& callback) {
- callback.Run(false);
+ callback.Run(true);
}
void FakeDebugDaemonClient::SetDebugMode(const std::string& subsystem,
@@ -35,6 +36,7 @@ void FakeDebugDaemonClient::SetDebugMode(const std::string& subsystem,
void FakeDebugDaemonClient::StartSystemTracing() {}
bool FakeDebugDaemonClient::RequestStopSystemTracing(
+ scoped_refptr<base::TaskRunner> task_runner,
const StopSystemTracingCallback& callback) {
std::string no_data;
callback.Run(base::RefCountedString::TakeString(&no_data));
diff --git a/chromeos/dbus/fake_debug_daemon_client.h b/chromeos/dbus/fake_debug_daemon_client.h
index 74d933f..b405410 100644
--- a/chromeos/dbus/fake_debug_daemon_client.h
+++ b/chromeos/dbus/fake_debug_daemon_client.h
@@ -21,11 +21,13 @@ class CHROMEOS_EXPORT FakeDebugDaemonClient : public DebugDaemonClient {
virtual void Init(dbus::Bus* bus) OVERRIDE;
virtual void DumpDebugLogs(bool is_compressed,
base::File file,
+ scoped_refptr<base::TaskRunner> task_runner,
const GetDebugLogsCallback& callback) OVERRIDE;
virtual void SetDebugMode(const std::string& subsystem,
const SetDebugModeCallback& callback) OVERRIDE;
virtual void StartSystemTracing() OVERRIDE;
virtual bool RequestStopSystemTracing(
+ scoped_refptr<base::TaskRunner> task_runner,
const StopSystemTracingCallback& callback) OVERRIDE;
virtual void GetRoutes(bool numeric,
bool ipv6,
diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc
index 63a44fc..0db1405 100644
--- a/content/browser/tracing/tracing_controller_impl.cc
+++ b/content/browser/tracing/tracing_controller_impl.cc
@@ -340,10 +340,14 @@ void TracingControllerImpl::OnDisableRecordingDone(
++pending_disable_recording_ack_count_;
#if defined(OS_CHROMEOS)
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->
- RequestStopSystemTracing(
- base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked,
- base::Unretained(this)));
+ scoped_refptr<base::TaskRunner> task_runner =
+ BrowserThread::GetBlockingPool();
+ chromeos::DBusThreadManager::Get()
+ ->GetDebugDaemonClient()
+ ->RequestStopSystemTracing(
+ task_runner,
+ base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked,
+ base::Unretained(this)));
#elif defined(OS_WIN)
EtwSystemEventConsumer::GetInstance()->StopSystemTracing(
base::Bind(&TracingControllerImpl::OnEndSystemTracingAcked,