summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcreis <creis@chromium.org>2015-02-17 13:46:17 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-17 21:46:48 +0000
commit34ca873ecd8905a90f9acfc6e840fb84671895af (patch)
tree78766415c7f446f85ebdaba6d86617a606b4105f
parent5bb8ae3e2c5270d6aa939056d2de24eb3b37f2ef (diff)
downloadchromium_src-34ca873ecd8905a90f9acfc6e840fb84671895af.zip
chromium_src-34ca873ecd8905a90f9acfc6e840fb84671895af.tar.gz
chromium_src-34ca873ecd8905a90f9acfc6e840fb84671895af.tar.bz2
Revert of Remove dependency on content from remoting_host. (patchset #5 id:160001 of https://codereview.chromium.org/929493002/)
Reason for revert: Compile failure on Linux ChromiumOS Ozone Builder: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Ozone%20Builder/builds/11867 Original issue's description: > Remove dependency on content from remoting_host. > > The host was depending on content just to access content::BrowserThread. > It's cleaner to just pass the references to the threads explicitly. > > BUG=458581 > > Committed: https://crrev.com/d5197934178ef0da1b630792cfbda8ddb6b34388 > Cr-Commit-Position: refs/heads/master@{#316648} TBR=kelvinp@chromium.org,sergeyu@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=458581 Review URL: https://codereview.chromium.org/923773003 Cr-Commit-Position: refs/heads/master@{#316661}
-rw-r--r--chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc9
-rw-r--r--remoting/host/BUILD.gn1
-rw-r--r--remoting/host/DEPS1
-rw-r--r--remoting/host/chromeos/clipboard_aura.cc96
-rw-r--r--remoting/host/chromeos/clipboard_aura.h16
-rw-r--r--remoting/host/chromeos/clipboard_aura_unittest.cc15
-rw-r--r--remoting/host/chromoting_host_context.cc65
-rw-r--r--remoting/host/chromoting_host_context.h9
-rw-r--r--remoting/host/input_injector_chromeos.cc4
-rw-r--r--remoting/remoting_host.gypi1
10 files changed, 132 insertions, 85 deletions
diff --git a/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc b/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
index 416db29..222c9e3 100644
--- a/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h"
#include "components/policy/core/common/policy_service.h"
-#include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h"
#include "extensions/common/url_pattern.h"
#include "net/url_request/url_request_context_getter.h"
@@ -97,13 +96,7 @@ scoped_ptr<NativeMessageHost> CreateIt2MeHost() {
host_factory->set_policy_service(g_browser_process->policy_service());
scoped_ptr<remoting::ChromotingHostContext> context =
remoting::ChromotingHostContext::CreateForChromeOS(
- make_scoped_refptr(g_browser_process->system_request_context()),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::IO),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::FILE));
+ make_scoped_refptr(g_browser_process->system_request_context()));
scoped_ptr<NativeMessageHost> host(new remoting::It2MeNativeMessagingHost(
context.Pass(), host_factory.Pass()));
return host.Pass();
diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn
index 12c6bd0..42bf79e 100644
--- a/remoting/host/BUILD.gn
+++ b/remoting/host/BUILD.gn
@@ -54,6 +54,7 @@ static_library("host") {
if (is_chromeos) {
deps += [
"//cc",
+ "//content",
"//ppapi/host",
"//skia",
"//ui/aura",
diff --git a/remoting/host/DEPS b/remoting/host/DEPS
index 3abc854..5c171ce 100644
--- a/remoting/host/DEPS
+++ b/remoting/host/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+ash",
"+cc/output",
+ "+content/public/browser",
"+components/policy/core/common",
"+extensions/browser/api/messaging",
"+jingle/glue",
diff --git a/remoting/host/chromeos/clipboard_aura.cc b/remoting/host/chromeos/clipboard_aura.cc
index e5eee10..7fca2df 100644
--- a/remoting/host/chromeos/clipboard_aura.cc
+++ b/remoting/host/chromeos/clipboard_aura.cc
@@ -5,6 +5,8 @@
#include "remoting/host/chromeos/clipboard_aura.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/timer/timer.h"
+#include "content/public/browser/browser_thread.h"
#include "remoting/base/constants.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/clipboard_stub.h"
@@ -20,31 +22,83 @@ const int64 kClipboardPollingIntervalMs = 500;
namespace remoting {
-ClipboardAura::ClipboardAura()
- : current_change_count_(0),
- polling_interval_(
- base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) {
+class ClipboardAura::Core {
+ public:
+ Core();
+
+ // Mirror the public interface.
+ void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard);
+ void InjectClipboardEvent(const protocol::ClipboardEvent& event);
+ void Stop();
+
+ // Overrides the clipboard polling interval for unit test.
+ void SetPollingIntervalForTesting(base::TimeDelta polling_interval);
+
+ private:
+ void CheckClipboardForChanges();
+
+ scoped_ptr<protocol::ClipboardStub> client_clipboard_;
+ scoped_ptr<base::RepeatingTimer<Core>> clipboard_polling_timer_;
+ uint64 current_change_count_;
+ base::TimeDelta polling_interval_;
+
+ DISALLOW_COPY_AND_ASSIGN(Core);
+};
+
+ClipboardAura::ClipboardAura(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
+ : core_(new Core()),
+ ui_task_runner_(ui_task_runner) {
}
ClipboardAura::~ClipboardAura() {
+ ui_task_runner_->DeleteSoon(FROM_HERE, core_.release());
}
void ClipboardAura::Start(
scoped_ptr<protocol::ClipboardStub> client_clipboard) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ ui_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&Core::Start, base::Unretained(core_.get()),
+ base::Passed(&client_clipboard)));
+}
- client_clipboard_ = client_clipboard.Pass();
+void ClipboardAura::InjectClipboardEvent(
+ const protocol::ClipboardEvent& event) {
+ ui_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&Core::InjectClipboardEvent,
+ base::Unretained(core_.get()), event));
+}
+
+void ClipboardAura::Stop() {
+ ui_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&Core::Stop, base::Unretained(core_.get())));
+};
+
+void ClipboardAura::SetPollingIntervalForTesting(
+ base::TimeDelta polling_interval) {
+ core_->SetPollingIntervalForTesting(polling_interval);
+}
+
+ClipboardAura::Core::Core()
+ : current_change_count_(0),
+ polling_interval_(
+ base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) {
+}
+
+void ClipboardAura::Core::Start(
+ scoped_ptr<protocol::ClipboardStub> client_clipboard) {
+ client_clipboard_.reset(client_clipboard.release());
// Aura doesn't provide a clipboard-changed notification. The only way to
// detect clipboard changes is by polling.
- clipboard_polling_timer_.Start(FROM_HERE, polling_interval_, this,
- &ClipboardAura::CheckClipboardForChanges);
+ clipboard_polling_timer_.reset(new base::RepeatingTimer<Core>());
+ clipboard_polling_timer_->Start(
+ FROM_HERE, polling_interval_, this,
+ &ClipboardAura::Core::CheckClipboardForChanges);
}
-void ClipboardAura::InjectClipboardEvent(
+void ClipboardAura::Core::InjectClipboardEvent(
const protocol::ClipboardEvent& event) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
// Currently we only handle UTF-8 text.
if (event.mime_type().compare(kMimeTypeTextUtf8) != 0) {
return;
@@ -58,23 +112,17 @@ void ClipboardAura::InjectClipboardEvent(
current_change_count_++;
}
-void ClipboardAura::Stop() {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- clipboard_polling_timer_.Stop();
+void ClipboardAura::Core::Stop() {
+ clipboard_polling_timer_.reset();
client_clipboard_.reset();
-};
+}
-void ClipboardAura::SetPollingIntervalForTesting(
+void ClipboardAura::Core::SetPollingIntervalForTesting(
base::TimeDelta polling_interval) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
polling_interval_ = polling_interval;
}
-void ClipboardAura::CheckClipboardForChanges() {
- DCHECK(thread_checker_.CalledOnValidThread());
-
+void ClipboardAura::Core::CheckClipboardForChanges() {
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
uint64 change_count =
clipboard->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE);
@@ -96,7 +144,9 @@ void ClipboardAura::CheckClipboardForChanges() {
}
scoped_ptr<Clipboard> Clipboard::Create() {
- return make_scoped_ptr(new ClipboardAura());
+ return make_scoped_ptr(
+ new ClipboardAura(content::BrowserThread::GetMessageLoopProxyForThread(
+ content::BrowserThread::UI)));
}
} // namespace remoting
diff --git a/remoting/host/chromeos/clipboard_aura.h b/remoting/host/chromeos/clipboard_aura.h
index e561e2e..9907fb6d 100644
--- a/remoting/host/chromeos/clipboard_aura.h
+++ b/remoting/host/chromeos/clipboard_aura.h
@@ -6,8 +6,7 @@
#define REMOTING_HOST_CLIPBOARD_AURA_H_
#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "base/timer/timer.h"
+#include "base/single_thread_task_runner.h"
#include "remoting/host/clipboard.h"
namespace remoting {
@@ -26,9 +25,11 @@ class ClipboardStub;
// The public API of this class can be called in any thread as internally it
// always posts the call to the |ui_task_runner|. On ChromeOS, that should
// be the UI thread of the browser process.
+//
class ClipboardAura : public Clipboard {
public:
- explicit ClipboardAura();
+ explicit ClipboardAura(
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
~ClipboardAura() override;
// Clipboard interface.
@@ -40,13 +41,10 @@ class ClipboardAura : public Clipboard {
void SetPollingIntervalForTesting(base::TimeDelta polling_interval);
private:
- void CheckClipboardForChanges();
+ class Core;
- base::ThreadChecker thread_checker_;
- scoped_ptr<protocol::ClipboardStub> client_clipboard_;
- base::RepeatingTimer<ClipboardAura> clipboard_polling_timer_;
- uint64 current_change_count_;
- base::TimeDelta polling_interval_;
+ scoped_ptr<Core> core_;
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
DISALLOW_COPY_AND_ASSIGN(ClipboardAura);
};
diff --git a/remoting/host/chromeos/clipboard_aura_unittest.cc b/remoting/host/chromeos/clipboard_aura_unittest.cc
index 66836b6..5201c11 100644
--- a/remoting/host/chromeos/clipboard_aura_unittest.cc
+++ b/remoting/host/chromeos/clipboard_aura_unittest.cc
@@ -55,6 +55,7 @@ class ClipboardAuraTest : public testing::Test {
void StopAndResetClipboard();
base::MessageLoopForUI message_loop_;
+ base::RunLoop run_loop_;
ClientClipboard* client_clipboard_;
scoped_ptr<ClipboardAura> clipboard_;
};
@@ -70,13 +71,12 @@ void ClipboardAuraTest::SetUp() {
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
message_loop_.message_loop_proxy();
client_clipboard_ = new ClientClipboard();
- clipboard_.reset(new ClipboardAura());
+ clipboard_.reset(new ClipboardAura(task_runner));
+ clipboard_->Start(make_scoped_ptr(client_clipboard_));
EXPECT_GT(TestTimeouts::tiny_timeout(), kTestOverridePollingInterval * 10)
<< "The test timeout should be greater than the polling interval";
clipboard_->SetPollingIntervalForTesting(kTestOverridePollingInterval);
-
- clipboard_->Start(make_scoped_ptr(client_clipboard_));
}
void ClipboardAuraTest::TearDown() {
@@ -95,7 +95,7 @@ TEST_F(ClipboardAuraTest, WriteToClipboard) {
clipboard_->InjectClipboardEvent(event);
StopAndResetClipboard();
- base::RunLoop().RunUntilIdle();
+ run_loop_.RunUntilIdle();
std::string clipboard_data;
ui::Clipboard* aura_clipboard = ui::Clipboard::GetForCurrentThread();
@@ -106,8 +106,6 @@ TEST_F(ClipboardAuraTest, WriteToClipboard) {
}
TEST_F(ClipboardAuraTest, MonitorClipboardChanges) {
- base::RunLoop().RunUntilIdle();
-
{
// |clipboard_writer| will write to the clipboard when it goes out of scope.
ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE);
@@ -118,15 +116,14 @@ TEST_F(ClipboardAuraTest, MonitorClipboardChanges) {
InjectClipboardEvent(Property(&protocol::ClipboardEvent::data,
Eq("Test data.")))).Times(1);
- base::RunLoop run_loop;
message_loop_.PostDelayedTask(
FROM_HERE, base::Bind(&ClipboardAuraTest_MonitorClipboardChanges_Test::
StopAndResetClipboard,
base::Unretained(this)),
TestTimeouts::tiny_timeout());
- message_loop_.PostDelayedTask(FROM_HERE, run_loop.QuitClosure(),
+ message_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
TestTimeouts::tiny_timeout());
- run_loop.Run();
+ message_loop_.Run();
}
} // namespace remoting
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index e2943ff..319cc77 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -4,8 +4,8 @@
#include "remoting/host/chromoting_host_context.h"
-#include "base/bind.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/browser_thread.h"
#include "remoting/base/auto_thread.h"
#include "remoting/base/url_request_context_getter.h"
@@ -127,39 +127,50 @@ scoped_ptr<ChromotingHostContext> ChromotingHostContext::Create(
}
#if defined(OS_CHROMEOS)
+namespace {
+// Retrieves the task_runner from the browser thread with |id|.
+scoped_refptr<AutoThreadTaskRunner> WrapBrowserThread(
+ content::BrowserThread::ID id) {
+ // AutoThreadTaskRunner is a TaskRunner with the special property that it will
+ // continue to process tasks until no references remain, at least. The
+ // QuitClosure we usually pass does the simple thing of stopping the
+ // underlying TaskRunner. Since we are re-using the ui_task_runner of the
+ // browser thread, we cannot stop it explicitly. Therefore, base::DoNothing
+ // is passed in as the quit closure.
+ // TODO(kelvinp): Fix this (See crbug.com/428187).
+ return new AutoThreadTaskRunner(
+ content::BrowserThread::GetMessageLoopProxyForThread(id).get(),
+ base::Bind(&base::DoNothing));
+}
+
+} // namespace
// static
scoped_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS(
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) {
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
DCHECK(url_request_context_getter.get());
-
- // AutoThreadTaskRunner is a TaskRunner with the special property that it will
- // continue to process tasks until no references remain, at least. The
- // QuitClosure we usually pass does the simple thing of stopping the
- // underlying TaskRunner. Since we are re-using browser's threads, we cannot
- // stop them explicitly. Therefore, base::DoNothing is passed in as the quit
- // closure.
- scoped_refptr<AutoThreadTaskRunner> io_auto_task_runner =
- new AutoThreadTaskRunner(io_task_runner, base::Bind(&base::DoNothing));
- scoped_refptr<AutoThreadTaskRunner> file_auto_task_runner =
- new AutoThreadTaskRunner(file_task_runner, base::Bind(&base::DoNothing));
- scoped_refptr<AutoThreadTaskRunner> ui_auto_task_runner =
- new AutoThreadTaskRunner(ui_task_runner, base::Bind(&base::DoNothing));
-
- // Use browser's file thread as the joiner as it is the only browser-thread
+ // Use BrowserThread::FILE as the joiner as it is the only browser-thread
// that allows blocking I/O, which is required by thread joining.
+ // TODO(kelvinp): Fix AutoThread so that it can be joinable on task runners
+ // that disallow I/O (crbug.com/428466).
+ scoped_refptr<AutoThreadTaskRunner> file_task_runner =
+ WrapBrowserThread(content::BrowserThread::FILE);
+
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
+ WrapBrowserThread(content::BrowserThread::UI);
+
return make_scoped_ptr(new ChromotingHostContext(
- ui_auto_task_runner,
- AutoThread::Create("ChromotingAudioThread", file_auto_task_runner),
- file_auto_task_runner,
- ui_auto_task_runner, // input_task_runner
- io_auto_task_runner, // network_task_runner
- ui_auto_task_runner, // video_capture_task_runner
- AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner),
+ ui_task_runner,
+ AutoThread::CreateWithType("ChromotingAudioThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
+ file_task_runner,
+ AutoThread::CreateWithType("ChromotingInputThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
+ WrapBrowserThread(content::BrowserThread::IO), // network_task_runner
+ ui_task_runner, // video_capture_task_runner
+ AutoThread::CreateWithType("ChromotingEncodeThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
url_request_context_getter));
}
#endif // defined(OS_CHROMEOS)
diff --git a/remoting/host/chromoting_host_context.h b/remoting/host/chromoting_host_context.h
index af6216a..9de7067 100644
--- a/remoting/host/chromoting_host_context.h
+++ b/remoting/host/chromoting_host_context.h
@@ -9,10 +9,6 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-namespace base {
-class SingleThreadTaskRunner;
-} // namespace base
-
namespace net {
class URLRequestContextGetter;
} // namespace net
@@ -43,10 +39,7 @@ class ChromotingHostContext {
// the IO Thread of the browser process).
// Instead, we re-use the |url_request_context_getter| in the browser process.
static scoped_ptr<ChromotingHostContext> CreateForChromeOS(
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
#endif // defined(OS_CHROMEOS)
~ChromotingHostContext();
diff --git a/remoting/host/input_injector_chromeos.cc b/remoting/host/input_injector_chromeos.cc
index 5691191..26eeae1 100644
--- a/remoting/host/input_injector_chromeos.cc
+++ b/remoting/host/input_injector_chromeos.cc
@@ -78,9 +78,12 @@ InputInjectorChromeos::Core::Core(scoped_ptr<ui::SystemInputInjector> delegate,
ui::InputController* input_controller)
: delegate_(delegate.Pass()),
input_controller_(input_controller),
+ // Implemented by remoting::ClipboardAura.
+ clipboard_(Clipboard::Create()),
saved_auto_repeat_enabled_(false) {
DCHECK(delegate_);
DCHECK(input_controller_);
+ DCHECK(clipboard_);
}
void InputInjectorChromeos::Core::InjectClipboardEvent(
@@ -156,7 +159,6 @@ void InputInjectorChromeos::Core::InjectMouseEvent(const MouseEvent& event) {
void InputInjectorChromeos::Core::Start(
scoped_ptr<protocol::ClipboardStub> client_clipboard) {
- clipboard_.reset(Clipboard::Create());
clipboard_->Start(client_clipboard.Pass());
point_transformer_.reset(new PointTransformer());
}
diff --git a/remoting/remoting_host.gypi b/remoting/remoting_host.gypi
index 8a499f5..733f17f 100644
--- a/remoting/remoting_host.gypi
+++ b/remoting/remoting_host.gypi
@@ -84,6 +84,7 @@
['chromeos==1', {
'dependencies' : [
'../cc/cc.gyp:cc',
+ '../content/content.gyp:content',
'../ppapi/ppapi_internal.gyp:ppapi_host',
'../skia/skia.gyp:skia',
'../ui/aura/aura.gyp:aura',