| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/appcache/appcache_dispatcher.h" | 10 #include "content/common/appcache/appcache_dispatcher.h" |
| 11 #include "content/common/db_message_filter.h" | 11 #include "content/common/db_message_filter.h" |
| 12 #include "content/common/web_database_observer_impl.h" | 12 #include "content/common/web_database_observer_impl.h" |
| 13 #include "content/common/worker_messages.h" | 13 #include "content/common/worker_messages.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/worker/webworker_stub.h" | |
| 16 #include "content/worker/websharedworker_stub.h" | 15 #include "content/worker/websharedworker_stub.h" |
| 17 #include "content/worker/worker_webkitplatformsupport_impl.h" | 16 #include "content/worker/worker_webkitplatformsupport_impl.h" |
| 18 #include "ipc/ipc_sync_channel.h" | 17 #include "ipc/ipc_sync_channel.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlobRegistry.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlobRegistry.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 23 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
| 24 | 23 |
| 25 using WebKit::WebRuntimeFeatures; | 24 using WebKit::WebRuntimeFeatures; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) | 85 IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) |
| 87 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) | 86 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) |
| 88 IPC_MESSAGE_UNHANDLED(handled = false) | 87 IPC_MESSAGE_UNHANDLED(handled = false) |
| 89 IPC_END_MESSAGE_MAP() | 88 IPC_END_MESSAGE_MAP() |
| 90 return handled; | 89 return handled; |
| 91 } | 90 } |
| 92 | 91 |
| 93 void WorkerThread::OnCreateWorker( | 92 void WorkerThread::OnCreateWorker( |
| 94 const WorkerProcessMsg_CreateWorker_Params& params) { | 93 const WorkerProcessMsg_CreateWorker_Params& params) { |
| 95 WorkerAppCacheInitInfo appcache_init_info( | 94 WorkerAppCacheInitInfo appcache_init_info( |
| 96 params.is_shared, params.creator_process_id, | 95 params.creator_process_id, |
| 97 params.creator_appcache_host_id, | |
| 98 params.shared_worker_appcache_id); | 96 params.shared_worker_appcache_id); |
| 99 | 97 |
| 100 // WebWorkerStub and WebSharedWorkerStub own themselves. | 98 // WebSharedWorkerStub own themselves. |
| 101 if (params.is_shared) | 99 new WebSharedWorkerStub(params.name, params.route_id, appcache_init_info); |
| 102 new WebSharedWorkerStub(params.name, params.route_id, appcache_init_info); | |
| 103 else | |
| 104 new WebWorkerStub(params.url, params.route_id, appcache_init_info); | |
| 105 } | 100 } |
| 106 | 101 |
| 107 // The browser process is likely dead. Terminate all workers. | 102 // The browser process is likely dead. Terminate all workers. |
| 108 void WorkerThread::OnChannelError() { | 103 void WorkerThread::OnChannelError() { |
| 109 set_on_channel_error_called(true); | 104 set_on_channel_error_called(true); |
| 110 | 105 |
| 111 for (WorkerStubsList::iterator it = worker_stubs_.begin(); | 106 for (WorkerStubsList::iterator it = worker_stubs_.begin(); |
| 112 it != worker_stubs_.end(); ++it) { | 107 it != worker_stubs_.end(); ++it) { |
| 113 (*it)->OnChannelError(); | 108 (*it)->OnChannelError(); |
| 114 } | 109 } |
| 115 } | 110 } |
| 116 | 111 |
| 117 void WorkerThread::RemoveWorkerStub(WebWorkerStubBase* stub) { | 112 void WorkerThread::RemoveWorkerStub(WebSharedWorkerStub* stub) { |
| 118 worker_stubs_.erase(stub); | 113 worker_stubs_.erase(stub); |
| 119 } | 114 } |
| 120 | 115 |
| 121 void WorkerThread::AddWorkerStub(WebWorkerStubBase* stub) { | 116 void WorkerThread::AddWorkerStub(WebSharedWorkerStub* stub) { |
| 122 worker_stubs_.insert(stub); | 117 worker_stubs_.insert(stub); |
| 123 } | 118 } |
| OLD | NEW |