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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | « content/shell/renderer/webkit_test_runner.cc ('k') | content/shell/shell_browser_main.cc » ('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) 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/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.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/path_service.h" 10 #include "base/path_service.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 PlatformCleanUp(); 70 PlatformCleanUp();
71 71
72 for (size_t i = 0; i < windows_.size(); ++i) { 72 for (size_t i = 0; i < windows_.size(); ++i) {
73 if (windows_[i] == this) { 73 if (windows_[i] == this) {
74 windows_.erase(windows_.begin() + i); 74 windows_.erase(windows_.begin() + i);
75 break; 75 break;
76 } 76 }
77 } 77 }
78 78
79 if (windows_.empty() && quit_message_loop_) 79 if (windows_.empty() && quit_message_loop_)
80 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 80 base::MessageLoop::current()->PostTask(FROM_HERE,
81 base::MessageLoop::QuitClosure());
81 } 82 }
82 83
83 Shell* Shell::CreateShell(WebContents* web_contents) { 84 Shell* Shell::CreateShell(WebContents* web_contents) {
84 Shell* shell = new Shell(web_contents); 85 Shell* shell = new Shell(web_contents);
85 shell->PlatformCreateWindow(kTestWindowWidth, kTestWindowHeight); 86 shell->PlatformCreateWindow(kTestWindowWidth, kTestWindowHeight);
86 87
87 shell->web_contents_.reset(web_contents); 88 shell->web_contents_.reset(web_contents);
88 web_contents->SetDelegate(shell); 89 web_contents->SetDelegate(shell);
89 90
90 shell->PlatformSetContents(); 91 shell->PlatformSetContents();
91 92
92 shell->PlatformResizeSubViews(); 93 shell->PlatformResizeSubViews();
93 94
94 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 95 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
95 web_contents->GetMutableRendererPrefs()->use_custom_colors = false; 96 web_contents->GetMutableRendererPrefs()->use_custom_colors = false;
96 web_contents->GetRenderViewHost()->SyncRendererPrefs(); 97 web_contents->GetRenderViewHost()->SyncRendererPrefs();
97 } 98 }
98 99
99 return shell; 100 return shell;
100 } 101 }
101 102
102 void Shell::CloseAllWindows() { 103 void Shell::CloseAllWindows() {
103 base::AutoReset<bool> auto_reset(&quit_message_loop_, false); 104 base::AutoReset<bool> auto_reset(&quit_message_loop_, false);
104 DevToolsManager::GetInstance()->CloseAllClientHosts(); 105 DevToolsManager::GetInstance()->CloseAllClientHosts();
105 std::vector<Shell*> open_windows(windows_); 106 std::vector<Shell*> open_windows(windows_);
106 for (size_t i = 0; i < open_windows.size(); ++i) 107 for (size_t i = 0; i < open_windows.size(); ++i)
107 open_windows[i]->Close(); 108 open_windows[i]->Close();
108 MessageLoop::current()->RunUntilIdle(); 109 base::MessageLoop::current()->RunUntilIdle();
109 } 110 }
110 111
111 void Shell::SetShellCreatedCallback( 112 void Shell::SetShellCreatedCallback(
112 base::Callback<void(Shell*)> shell_created_callback) { 113 base::Callback<void(Shell*)> shell_created_callback) {
113 DCHECK(shell_created_callback_.is_null()); 114 DCHECK(shell_created_callback_.is_null());
114 shell_created_callback_ = shell_created_callback; 115 shell_created_callback_ = shell_created_callback;
115 } 116 }
116 117
117 Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) { 118 Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
118 for (size_t i = 0; i < windows_.size(); ++i) { 119 for (size_t i = 0; i < windows_.size(); ++i) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 322 }
322 } else if (type == NOTIFICATION_WEB_CONTENTS_DESTROYED) { 323 } else if (type == NOTIFICATION_WEB_CONTENTS_DESTROYED) {
323 devtools_frontend_ = NULL; 324 devtools_frontend_ = NULL;
324 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, source); 325 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, source);
325 } else { 326 } else {
326 NOTREACHED(); 327 NOTREACHED();
327 } 328 }
328 } 329 }
329 330
330 } // namespace content 331 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/webkit_test_runner.cc ('k') | content/shell/shell_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698