| Index: remoting/host/chromoting_host_context_impl_chromeos.cc
|
| diff --git a/remoting/host/chromoting_host_context_impl_chromeos.cc b/remoting/host/chromoting_host_context_impl_chromeos.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5bf508a556efa8d08b12b3b0b79a46fffa6f5431
|
| --- /dev/null
|
| +++ b/remoting/host/chromoting_host_context_impl_chromeos.cc
|
| @@ -0,0 +1,69 @@
|
| +// Copyright (c) 2012 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 "remoting/host/chromoting_host_context.h"
|
| +
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +#include "net/url_request/url_request_context_getter.h"
|
| +#include "remoting/base/auto_thread.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +namespace {
|
| +// Retrieves the task_runner from the browser thread with |id|.
|
| +AutoThreadTaskRunner* GetTaskRunner(content::BrowserThread::ID id) {
|
| + return new AutoThreadTaskRunner(
|
| + content::BrowserThread::GetMessageLoopProxyForThread(id).get(),
|
| + base::Bind(&base::DoNothing));
|
| +}
|
| +
|
| +class ChromotingHostContextImpl : public ChromotingHostContext {
|
| + public:
|
| + ChromotingHostContextImpl(AutoThreadTaskRunner* ui_task_runner);
|
| +
|
| + private:
|
| + virtual ~ChromotingHostContextImpl() override;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +// static
|
| +scoped_refptr<ChromotingHostContext> ChromotingHostContext::Create(
|
| + scoped_refptr<AutoThreadTaskRunner> ui_task_runner) {
|
| + return new ChromotingHostContextImpl(ui_task_runner.get());
|
| +}
|
| +
|
| +ChromotingHostContextImpl::ChromotingHostContextImpl(
|
| + AutoThreadTaskRunner* ui_task_runner)
|
| + : ChromotingHostContext(ui_task_runner) {
|
| + DCHECK(ui_task_runner_->BelongsToCurrentThread());
|
| +
|
| + // Thread assignments and re-using existing browser sources
|
| + // (URLRequestContextGetter) must be performed on the UI thread of the
|
| + // browser process.
|
| + file_task_runner_ = GetTaskRunner(content::BrowserThread::FILE);
|
| + network_task_runner_ = GetTaskRunner(content::BrowserThread::IO);
|
| + video_capture_task_runner_ = GetTaskRunner(content::BrowserThread::UI);
|
| +
|
| + // Each instance of BasicURLRequestContext spawns two extra threads.
|
| + // Reuse the url_request_context_getter of the I/O Thread to avoid creating
|
| + // extra threads on the UI thread.
|
| + url_request_context_getter_ = g_browser_process->system_request_context();
|
| +
|
| + // Thread joining is blocking and it can only be done on threads that allows
|
| + // blocking I/O. Uses the |file_task_runner| as the joiner.
|
| + input_task_runner_ = AutoThread::CreateWithType(
|
| + "ChromotingInputThread", file_task_runner_, base::MessageLoop::TYPE_IO);
|
| + audio_task_runner_ = AutoThread::CreateWithType(
|
| + "ChromotingAudioThread", file_task_runner_, base::MessageLoop::TYPE_IO);
|
| + video_encode_task_runner_ =
|
| + AutoThread::Create("ChromotingEncodeThread", file_task_runner_);
|
| +
|
| +}
|
| +
|
| +ChromotingHostContextImpl::~ChromotingHostContextImpl() {
|
| +}
|
| +
|
| +} // namespace remoting
|
|
|