Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1634)

Unified Diff: mojo/examples/html_viewer/webthread_impl.cc

Issue 393983004: Move mojo/examples/html_viewer to mojo/services/html_viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nuke 'examples' namespace Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/html_viewer/webthread_impl.h ('k') | mojo/examples/html_viewer/weburlloader_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/html_viewer/webthread_impl.cc
diff --git a/mojo/examples/html_viewer/webthread_impl.cc b/mojo/examples/html_viewer/webthread_impl.cc
deleted file mode 100644
index 1173a257ea289568f155b108462f12a95ea8b672..0000000000000000000000000000000000000000
--- a/mojo/examples/html_viewer/webthread_impl.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-// 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.
-
-// An implementation of WebThread in terms of base::MessageLoop and
-// base::Thread
-
-#include "mojo/examples/html_viewer/webthread_impl.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "base/pending_task.h"
-#include "base/threading/platform_thread.h"
-
-namespace mojo {
-namespace examples {
-
-WebThreadBase::WebThreadBase() {}
-WebThreadBase::~WebThreadBase() {}
-
-class WebThreadBase::TaskObserverAdapter
- : public base::MessageLoop::TaskObserver {
- public:
- TaskObserverAdapter(WebThread::TaskObserver* observer)
- : observer_(observer) {}
-
- virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
- observer_->willProcessTask();
- }
-
- virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
- observer_->didProcessTask();
- }
-
-private:
- WebThread::TaskObserver* observer_;
-};
-
-void WebThreadBase::addTaskObserver(TaskObserver* observer) {
- CHECK(isCurrentThread());
- std::pair<TaskObserverMap::iterator, bool> result = task_observer_map_.insert(
- std::make_pair(observer, static_cast<TaskObserverAdapter*>(NULL)));
- if (result.second)
- result.first->second = new TaskObserverAdapter(observer);
- base::MessageLoop::current()->AddTaskObserver(result.first->second);
-}
-
-void WebThreadBase::removeTaskObserver(TaskObserver* observer) {
- CHECK(isCurrentThread());
- TaskObserverMap::iterator iter = task_observer_map_.find(observer);
- if (iter == task_observer_map_.end())
- return;
- base::MessageLoop::current()->RemoveTaskObserver(iter->second);
- delete iter->second;
- task_observer_map_.erase(iter);
-}
-
-WebThreadImpl::WebThreadImpl(const char* name)
- : thread_(new base::Thread(name)) {
- thread_->Start();
-}
-
-void WebThreadImpl::postTask(Task* task) {
- thread_->message_loop()->PostTask(
- FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task)));
-}
-
-void WebThreadImpl::postDelayedTask(Task* task, long long delay_ms) {
- thread_->message_loop()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&blink::WebThread::Task::run, base::Owned(task)),
- base::TimeDelta::FromMilliseconds(delay_ms));
-}
-
-void WebThreadImpl::enterRunLoop() {
- CHECK(isCurrentThread());
- CHECK(!thread_->message_loop()->is_running()); // We don't support nesting.
- thread_->message_loop()->Run();
-}
-
-void WebThreadImpl::exitRunLoop() {
- CHECK(isCurrentThread());
- CHECK(thread_->message_loop()->is_running());
- thread_->message_loop()->Quit();
-}
-
-bool WebThreadImpl::isCurrentThread() const {
- return thread_->thread_id() == base::PlatformThread::CurrentId();
-}
-
-WebThreadImpl::~WebThreadImpl() {
- thread_->Stop();
-}
-
-WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
- base::MessageLoopProxy* message_loop)
- : message_loop_(message_loop) {}
-
-void WebThreadImplForMessageLoop::postTask(Task* task) {
- message_loop_->PostTask(
- FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task)));
-}
-
-void WebThreadImplForMessageLoop::postDelayedTask(Task* task,
- long long delay_ms) {
- message_loop_->PostDelayedTask(
- FROM_HERE,
- base::Bind(&blink::WebThread::Task::run, base::Owned(task)),
- base::TimeDelta::FromMilliseconds(delay_ms));
-}
-
-void WebThreadImplForMessageLoop::enterRunLoop() {
- CHECK(isCurrentThread());
- // We don't support nesting.
- CHECK(!base::MessageLoop::current()->is_running());
- base::MessageLoop::current()->Run();
-}
-
-void WebThreadImplForMessageLoop::exitRunLoop() {
- CHECK(isCurrentThread());
- CHECK(base::MessageLoop::current()->is_running());
- base::MessageLoop::current()->Quit();
-}
-
-bool WebThreadImplForMessageLoop::isCurrentThread() const {
- return message_loop_->BelongsToCurrentThread();
-}
-
-WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {}
-
-} // namespace examples
-} // namespace mojo
« no previous file with comments | « mojo/examples/html_viewer/webthread_impl.h ('k') | mojo/examples/html_viewer/weburlloader_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698