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

Side by Side Diff: webkit/support/webkit_support.cc

Issue 9384024: Prefer ScopedNestableTaskAllower over manual save/restore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
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 "webkit/support/webkit_support.h" 5 #include "webkit/support/webkit_support.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 class WebKitClientMessageLoopImpl 208 class WebKitClientMessageLoopImpl
209 : public WebDevToolsAgentClient::WebKitClientMessageLoop { 209 : public WebDevToolsAgentClient::WebKitClientMessageLoop {
210 public: 210 public:
211 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {} 211 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) {}
212 virtual ~WebKitClientMessageLoopImpl() { 212 virtual ~WebKitClientMessageLoopImpl() {
213 message_loop_ = NULL; 213 message_loop_ = NULL;
214 } 214 }
215 virtual void run() { 215 virtual void run() {
216 bool old_state = message_loop_->NestableTasksAllowed(); 216 MessageLoop::ScopedNestableTaskAllower allow(message_loop_);
217 message_loop_->SetNestableTasksAllowed(true);
218 message_loop_->Run(); 217 message_loop_->Run();
219 message_loop_->SetNestableTasksAllowed(old_state);
220 } 218 }
221 virtual void quitNow() { 219 virtual void quitNow() {
222 message_loop_->QuitNow(); 220 message_loop_->QuitNow();
223 } 221 }
224 private: 222 private:
225 MessageLoop* message_loop_; 223 MessageLoop* message_loop_;
226 }; 224 };
227 225
228 webkit_support::GraphicsContext3DImplementation 226 webkit_support::GraphicsContext3DImplementation
229 g_graphics_context_3d_implementation = 227 g_graphics_context_3d_implementation =
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 bool MessageLoopNestableTasksAllowed() { 441 bool MessageLoopNestableTasksAllowed() {
444 return MessageLoop::current()->NestableTasksAllowed(); 442 return MessageLoop::current()->NestableTasksAllowed();
445 } 443 }
446 444
447 void MessageLoopSetNestableTasksAllowed(bool allowed) { 445 void MessageLoopSetNestableTasksAllowed(bool allowed) {
448 MessageLoop::current()->SetNestableTasksAllowed(allowed); 446 MessageLoop::current()->SetNestableTasksAllowed(allowed);
449 } 447 }
450 448
451 void DispatchMessageLoop() { 449 void DispatchMessageLoop() {
452 MessageLoop* current = MessageLoop::current(); 450 MessageLoop* current = MessageLoop::current();
453 bool old_state = current->NestableTasksAllowed(); 451 MessageLoop::ScopedNestableTaskAllower allow(current);
454 current->SetNestableTasksAllowed(true);
455 current->RunAllPending(); 452 current->RunAllPending();
456 current->SetNestableTasksAllowed(old_state);
457 } 453 }
458 454
459 WebDevToolsAgentClient::WebKitClientMessageLoop* CreateDevToolsMessageLoop() { 455 WebDevToolsAgentClient::WebKitClientMessageLoop* CreateDevToolsMessageLoop() {
460 return new WebKitClientMessageLoopImpl(); 456 return new WebKitClientMessageLoopImpl();
461 } 457 }
462 458
463 void PostDelayedTask(void (*func)(void*), void* context, int64 delay_ms) { 459 void PostDelayedTask(void (*func)(void*), void* context, int64 delay_ms) {
464 MessageLoop::current()->PostDelayedTask( 460 MessageLoop::current()->PostDelayedTask(
465 FROM_HERE, 461 FROM_HERE,
466 base::Bind(func, context), 462 base::Bind(func, context),
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // Logging 679 // Logging
684 void EnableWebCoreLogChannels(const std::string& channels) { 680 void EnableWebCoreLogChannels(const std::string& channels) {
685 webkit_glue::EnableWebCoreLogChannels(channels); 681 webkit_glue::EnableWebCoreLogChannels(channels);
686 } 682 }
687 683
688 void SetGamepadData(const WebKit::WebGamepads& pads) { 684 void SetGamepadData(const WebKit::WebGamepads& pads) {
689 test_environment->webkit_platform_support()->setGamepadData(pads); 685 test_environment->webkit_platform_support()->setGamepadData(pads);
690 } 686 }
691 687
692 } // namespace webkit_support 688 } // namespace webkit_support
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698