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

Side by Side Diff: content/shell/shell_browser_main.cc

Issue 8718012: Revert 111695 - Have content/ create and destroy its own threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | « content/shell/shell_browser_main.h ('k') | content/test/test_browser_thread.h » ('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) 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/shell/shell_browser_main.h" 5 #include "content/shell/shell_browser_main.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 22 matching lines...) Expand all
33 ShellBrowserMainParts::ShellBrowserMainParts( 33 ShellBrowserMainParts::ShellBrowserMainParts(
34 const content::MainFunctionParams& parameters) 34 const content::MainFunctionParams& parameters)
35 : BrowserMainParts() { 35 : BrowserMainParts() {
36 ShellContentBrowserClient* shell_browser_client = 36 ShellContentBrowserClient* shell_browser_client =
37 static_cast<ShellContentBrowserClient*>( 37 static_cast<ShellContentBrowserClient*>(
38 content::GetContentClient()->browser()); 38 content::GetContentClient()->browser());
39 shell_browser_client->set_shell_browser_main_parts(this); 39 shell_browser_client->set_shell_browser_main_parts(this);
40 } 40 }
41 41
42 ShellBrowserMainParts::~ShellBrowserMainParts() { 42 ShellBrowserMainParts::~ShellBrowserMainParts() {
43 base::ThreadRestrictions::SetIOAllowed(true);
44 io_thread()->message_loop()->PostTask(
45 FROM_HERE, base::IgnoreReturn<bool>(
46 base::Bind(&base::ThreadRestrictions::SetIOAllowed, true)));
47
48 browser_context_.reset();
49
50 resource_dispatcher_host_->download_file_manager()->Shutdown();
51 resource_dispatcher_host_->save_file_manager()->Shutdown();
52 resource_dispatcher_host_->Shutdown();
53 io_thread_.reset();
54 cache_thread_.reset();
55 process_launcher_thread_.reset();
56 file_thread_.reset();
57 resource_dispatcher_host_.reset(); // Kills WebKit thread.
58 db_thread_.reset();
43 } 59 }
44 60
45 void ShellBrowserMainParts::PreCreateThreads() { 61 void ShellBrowserMainParts::PreMainMessageLoopRun() {
62 db_thread_.reset(new BrowserProcessSubThread(BrowserThread::DB));
63 db_thread_->Start();
64 file_thread_.reset(new BrowserProcessSubThread(BrowserThread::FILE));
65 file_thread_->Start();
66 process_launcher_thread_.reset(
67 new BrowserProcessSubThread(BrowserThread::PROCESS_LAUNCHER));
68 process_launcher_thread_->Start();
69
70 base::Thread::Options options;
71 options.message_loop_type = MessageLoop::TYPE_IO;
72
73 cache_thread_.reset(new BrowserProcessSubThread(BrowserThread::CACHE));
74 cache_thread_->StartWithOptions(options);
75 io_thread_.reset(new BrowserProcessSubThread(BrowserThread::IO));
76 io_thread_->StartWithOptions(options);
77
46 browser_context_.reset(new ShellBrowserContext(this)); 78 browser_context_.reset(new ShellBrowserContext(this));
47 79
48 Shell::PlatformInitialize(); 80 Shell::PlatformInitialize();
49 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); 81 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider);
50 82
51 Shell::CreateNewWindow(browser_context_.get(), 83 Shell::CreateNewWindow(browser_context_.get(),
52 GetStartupURL(), 84 GetStartupURL(),
53 NULL, 85 NULL,
54 MSG_ROUTING_NONE, 86 MSG_ROUTING_NONE,
55 NULL); 87 NULL);
56 }
57 88
58 void ShellBrowserMainParts::PostMainMessageLoopRun() {
59 browser_context_.reset();
60
61 resource_dispatcher_host_->download_file_manager()->Shutdown();
62 resource_dispatcher_host_->save_file_manager()->Shutdown();
63 resource_dispatcher_host_->Shutdown();
64 }
65
66 void ShellBrowserMainParts::PreStopThread(BrowserThread::ID id) {
67 if (id == BrowserThread::WEBKIT) {
68 // It remains the embedder's responsibility to kill the WebKit
69 // thread. This happens when RDH is destroyed.
70 resource_dispatcher_host_.reset();
71 }
72 } 89 }
73 90
74 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { 91 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
75 return false; 92 return false;
76 } 93 }
77 94
78 ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() { 95 ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() {
79 if (!resource_dispatcher_host_.get()) { 96 if (!resource_dispatcher_host_.get()) {
80 ResourceQueue::DelegateSet resource_queue_delegates; 97 ResourceQueue::DelegateSet resource_queue_delegates;
81 resource_dispatcher_host_.reset( 98 resource_dispatcher_host_.reset(
82 new ResourceDispatcherHost(resource_queue_delegates)); 99 new ResourceDispatcherHost(resource_queue_delegates));
83 resource_dispatcher_host_->Initialize(); 100 resource_dispatcher_host_->Initialize();
84 } 101 }
85 return resource_dispatcher_host_.get(); 102 return resource_dispatcher_host_.get();
86 } 103 }
87 104
88 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { 105 ui::Clipboard* ShellBrowserMainParts::GetClipboard() {
89 if (!clipboard_.get()) 106 if (!clipboard_.get())
90 clipboard_.reset(new ui::Clipboard()); 107 clipboard_.reset(new ui::Clipboard());
91 return clipboard_.get(); 108 return clipboard_.get();
92 } 109 }
93 110
94 } // namespace 111 } // namespace
OLDNEW
« no previous file with comments | « content/shell/shell_browser_main.h ('k') | content/test/test_browser_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698