| OLD | NEW |
| 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" |
| 11 #include "content/child/appcache/appcache_frontend_impl.h" | 11 #include "content/child/appcache/appcache_frontend_impl.h" |
| 12 #include "content/child/db_message_filter.h" | 12 #include "content/child/db_message_filter.h" |
| 13 #include "content/child/indexed_db/indexed_db_message_filter.h" | 13 #include "content/child/indexed_db/indexed_db_message_filter.h" |
| 14 #include "content/child/runtime_features.h" | 14 #include "content/child/runtime_features.h" |
| 15 #include "content/child/web_database_observer_impl.h" | 15 #include "content/child/web_database_observer_impl.h" |
| 16 #include "content/common/child_process_messages.h" | 16 #include "content/common/child_process_messages.h" |
| 17 #include "content/common/worker_messages.h" | 17 #include "content/common/worker_messages.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/worker/websharedworker_stub.h" | 19 #include "content/worker/websharedworker_stub.h" |
| 20 #include "content/worker/worker_webkitplatformsupport_impl.h" | 20 #include "content/worker/worker_webkitplatformsupport_impl.h" |
| 21 #include "ipc/ipc_sync_channel.h" | 21 #include "ipc/ipc_sync_channel.h" |
| 22 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 22 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
| 23 #include "third_party/WebKit/public/web/WebDatabase.h" | 23 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 24 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
| 25 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 25 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
| 27 | 27 |
| 28 using WebKit::WebRuntimeFeatures; | 28 using blink::WebRuntimeFeatures; |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 | 31 |
| 32 static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls = | 32 static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls = |
| 33 LAZY_INSTANCE_INITIALIZER; | 33 LAZY_INSTANCE_INITIALIZER; |
| 34 | 34 |
| 35 WorkerThread::WorkerThread() { | 35 WorkerThread::WorkerThread() { |
| 36 lazy_tls.Pointer()->Set(this); | 36 lazy_tls.Pointer()->Set(this); |
| 37 webkit_platform_support_.reset(new WorkerWebKitPlatformSupportImpl( | 37 webkit_platform_support_.reset(new WorkerWebKitPlatformSupportImpl( |
| 38 thread_safe_sender(), | 38 thread_safe_sender(), |
| 39 sync_message_filter(), | 39 sync_message_filter(), |
| 40 quota_message_filter())); | 40 quota_message_filter())); |
| 41 WebKit::initialize(webkit_platform_support_.get()); | 41 blink::initialize(webkit_platform_support_.get()); |
| 42 | 42 |
| 43 appcache_dispatcher_.reset( | 43 appcache_dispatcher_.reset( |
| 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 WebKit::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_.get()); |
| 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 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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_.get()); |
| 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 WebKit::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() { |
| 85 return lazy_tls.Pointer()->Get(); | 85 return lazy_tls.Pointer()->Get(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { | 88 bool WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { |
| 89 // Appcache messages are handled by a delegate. | 89 // Appcache messages are handled by a delegate. |
| 90 if (appcache_dispatcher_->OnMessageReceived(msg)) | 90 if (appcache_dispatcher_->OnMessageReceived(msg)) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |