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

Side by Side Diff: content/utility/utility_main_thread.cc

Issue 23235002: Set up content in-process main threads via factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios Created 7 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/utility/utility_main_thread.h"
6
7 #include "content/child/child_process.h"
8 #include "content/utility/utility_thread_impl.h"
9
10 namespace content {
11
12 // We want to ensure there's only one utility thread running at a time, as there
13 // are many globals used in the utility process.
14 static base::LazyInstance<base::Lock> g_one_utility_thread_lock;
15
16 UtilityMainThread::UtilityMainThread(const std::string& channel_id)
17 : Thread("Chrome_InProcUtilityThread"), channel_id_(channel_id) {
18 }
19
20 UtilityMainThread::~UtilityMainThread() {
21 Stop();
22 }
23
24 void UtilityMainThread::Init() {
25 // We need to return right away or else the main thread that started us will
26 // hang.
27 base::MessageLoop::current()->PostTask(
28 FROM_HERE,
29 base::Bind(&UtilityMainThread::InitInternal, base::Unretained(this)));
30 }
31
32 void UtilityMainThread::CleanUp() {
33 child_process_.reset();
34
35 // See comment in RendererMainThread.
36 SetThreadWasQuitProperly(true);
37 g_one_utility_thread_lock.Get().Release();
38 }
39
40 void UtilityMainThread::InitInternal() {
41 g_one_utility_thread_lock.Get().Acquire();
42 child_process_.reset(new ChildProcess());
43 child_process_->set_main_thread(new UtilityThreadImpl(channel_id_));
44 }
45
46 base::Thread* CreateUtilityMainThread(const std::string& channel_id) {
47 return new UtilityMainThread(channel_id);
48 }
49
50 } // namespace content
OLDNEW
« content/browser/gpu/gpu_process_host.cc ('K') | « content/utility/utility_main_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698