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

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

Issue 155876: Revert r21117 as it caused reliability failures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/worker/worker_thread.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/worker/worker_thread.h" 5 #include "chrome/worker/worker_thread.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/thread_local.h" 8 #include "base/thread_local.h"
9 #include "chrome/common/worker_messages.h" 9 #include "chrome/common/worker_messages.h"
10 #include "chrome/worker/webworkerclient_proxy.h" 10 #include "chrome/worker/webworkerclient_proxy.h"
11 #include "chrome/worker/worker_webkitclient_impl.h" 11 #include "chrome/worker/worker_webkitclient_impl.h"
12 #include "webkit/api/public/WebKit.h" 12 #include "webkit/api/public/WebKit.h"
13 13
14 static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls( 14 static base::LazyInstance<base::ThreadLocalPointer<WorkerThread> > lazy_tls(
15 base::LINKER_INITIALIZED); 15 base::LINKER_INITIALIZED);
16 16
17 17
18 WorkerThread::WorkerThread() { 18 WorkerThread::WorkerThread()
19 lazy_tls.Pointer()->Set(this); 19 : ChildThread(base::Thread::Options(MessageLoop::TYPE_DEFAULT,
20 webkit_client_.reset(new WorkerWebKitClientImpl); 20 kV8StackSize)) {
21 WebKit::initialize(webkit_client_.get());
22 } 21 }
23 22
24 WorkerThread::~WorkerThread() { 23 WorkerThread::~WorkerThread() {
25 // Shutdown in reverse of the initialization order.
26 WebKit::shutdown();
27 lazy_tls.Pointer()->Set(NULL);
28 } 24 }
29 25
30 WorkerThread* WorkerThread::current() { 26 WorkerThread* WorkerThread::current() {
31 return lazy_tls.Pointer()->Get(); 27 return lazy_tls.Pointer()->Get();
32 } 28 }
33 29
30 void WorkerThread::Init() {
31 lazy_tls.Pointer()->Set(this);
32 ChildThread::Init();
33 webkit_client_.reset(new WorkerWebKitClientImpl);
34 WebKit::initialize(webkit_client_.get());
35 }
36
37 void WorkerThread::CleanUp() {
38 // Shutdown in reverse of the initialization order.
39
40 if (webkit_client_.get()) {
41 WebKit::shutdown();
42 webkit_client_.reset();
43 }
44
45 ChildThread::CleanUp();
46 lazy_tls.Pointer()->Set(NULL);
47 }
48
34 void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { 49 void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) {
35 IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) 50 IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg)
36 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) 51 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker)
37 IPC_END_MESSAGE_MAP() 52 IPC_END_MESSAGE_MAP()
38 } 53 }
39 54
40 void WorkerThread::OnCreateWorker(const GURL& url, int route_id) { 55 void WorkerThread::OnCreateWorker(const GURL& url, int route_id) {
41 // WebWorkerClientProxy owns itself. 56 // WebWorkerClientProxy owns itself.
42 new WebWorkerClientProxy(url, route_id); 57 new WebWorkerClientProxy(url, route_id);
43 } 58 }
OLDNEW
« no previous file with comments | « chrome/worker/worker_thread.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698