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

Side by Side Diff: content/worker/worker_thread.cc

Issue 63843002: Add ChildMessageFilter, a base class for renderer/worker cross-thread MessageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/worker/worker_thread.h" 5 #include "content/worker/worker_thread.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/thread_local.h" 9 #include "base/threading/thread_local.h"
10 #include "content/child/appcache/appcache_dispatcher.h" 10 #include "content/child/appcache/appcache_dispatcher.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 new AppCacheDispatcher(this, new AppCacheFrontendImpl())); 44 new AppCacheDispatcher(this, new AppCacheFrontendImpl()));
45 45
46 web_database_observer_impl_.reset( 46 web_database_observer_impl_.reset(
47 new WebDatabaseObserverImpl(sync_message_filter())); 47 new WebDatabaseObserverImpl(sync_message_filter()));
48 blink::WebDatabase::setObserver(web_database_observer_impl_.get()); 48 blink::WebDatabase::setObserver(web_database_observer_impl_.get());
49 db_message_filter_ = new DBMessageFilter(); 49 db_message_filter_ = new DBMessageFilter();
50 channel()->AddFilter(db_message_filter_.get()); 50 channel()->AddFilter(db_message_filter_.get());
51 51
52 indexed_db_message_filter_ = new IndexedDBMessageFilter( 52 indexed_db_message_filter_ = new IndexedDBMessageFilter(
53 thread_safe_sender()); 53 thread_safe_sender());
54 channel()->AddFilter(indexed_db_message_filter_.get()); 54 channel()->AddFilter(indexed_db_message_filter_->GetFilter());
55 55
56 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 56 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
57 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); 57 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
58 } 58 }
59 59
60 void WorkerThread::OnShutdown() { 60 void WorkerThread::OnShutdown() {
61 // The worker process is to be shut down gracefully. Ask the browser 61 // The worker process is to be shut down gracefully. Ask the browser
62 // process to shut it down forcefully instead and wait on the message, so that 62 // process to shut it down forcefully instead and wait on the message, so that
63 // there are no races between threads when the process is shutting down. 63 // there are no races between threads when the process is shutting down.
64 Send(new WorkerProcessHostMsg_ForceKillWorker()); 64 Send(new WorkerProcessHostMsg_ForceKillWorker());
65 } 65 }
66 66
67 WorkerThread::~WorkerThread() { 67 WorkerThread::~WorkerThread() {
68 } 68 }
69 69
70 void WorkerThread::Shutdown() { 70 void WorkerThread::Shutdown() {
71 ChildThread::Shutdown(); 71 ChildThread::Shutdown();
72 72
73 // Shutdown in reverse of the initialization order. 73 // Shutdown in reverse of the initialization order.
74 channel()->RemoveFilter(indexed_db_message_filter_.get()); 74 channel()->RemoveFilter(indexed_db_message_filter_->GetFilter());
75 indexed_db_message_filter_ = NULL; 75 indexed_db_message_filter_ = NULL;
76 76
77 channel()->RemoveFilter(db_message_filter_.get()); 77 channel()->RemoveFilter(db_message_filter_.get());
78 db_message_filter_ = NULL; 78 db_message_filter_ = NULL;
79 79
80 blink::shutdown(); 80 blink::shutdown();
81 lazy_tls.Pointer()->Set(NULL); 81 lazy_tls.Pointer()->Set(NULL);
82 } 82 }
83 83
84 WorkerThread* WorkerThread::current() { 84 WorkerThread* WorkerThread::current() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 void WorkerThread::RemoveWorkerStub(WebSharedWorkerStub* stub) { 130 void WorkerThread::RemoveWorkerStub(WebSharedWorkerStub* stub) {
131 worker_stubs_.erase(stub); 131 worker_stubs_.erase(stub);
132 } 132 }
133 133
134 void WorkerThread::AddWorkerStub(WebSharedWorkerStub* stub) { 134 void WorkerThread::AddWorkerStub(WebSharedWorkerStub* stub) {
135 worker_stubs_.insert(stub); 135 worker_stubs_.insert(stub);
136 } 136 }
137 137
138 } // namespace content 138 } // namespace content
OLDNEW
« content/child/cross_thread_message_filter.cc ('K') | « content/renderer/render_thread_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698