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

Side by Side Diff: webkit/tools/test_shell/test_shell_devtools_agent.cc

Issue 8215002: base::Bind: Cleanup in test_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 2 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) 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 "webkit/tools/test_shell/test_shell_devtools_agent.h" 5 #include "webkit/tools/test_shell/test_shell_devtools_agent.h"
6 6
7 #include "base/bind.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
8 #include "grit/webkit_chromium_resources.h" 9 #include "grit/webkit_chromium_resources.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
11 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h" 12 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h"
12 #include "webkit/tools/test_shell/test_shell_devtools_client.h" 13 #include "webkit/tools/test_shell/test_shell_devtools_client.h"
13 #include "webkit/glue/webkit_glue.h" 14 #include "webkit/glue/webkit_glue.h"
14 15
15 using WebKit::WebCString; 16 using WebKit::WebCString;
16 using WebKit::WebDevToolsAgent; 17 using WebKit::WebDevToolsAgent;
(...skipping 28 matching lines...) Expand all
45 // static 46 // static
46 void TestShellDevToolsAgent::DispatchMessageLoop() { 47 void TestShellDevToolsAgent::DispatchMessageLoop() {
47 MessageLoop* current = MessageLoop::current(); 48 MessageLoop* current = MessageLoop::current();
48 bool old_state = current->NestableTasksAllowed(); 49 bool old_state = current->NestableTasksAllowed();
49 current->SetNestableTasksAllowed(true); 50 current->SetNestableTasksAllowed(true);
50 current->RunAllPending(); 51 current->RunAllPending();
51 current->SetNestableTasksAllowed(old_state); 52 current->SetNestableTasksAllowed(old_state);
52 } 53 }
53 54
54 TestShellDevToolsAgent::TestShellDevToolsAgent() 55 TestShellDevToolsAgent::TestShellDevToolsAgent()
55 : ALLOW_THIS_IN_INITIALIZER_LIST(call_method_factory_(this)), 56 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
56 dev_tools_client_(NULL) { 57 dev_tools_client_(NULL) {
57 static int dev_tools_agent_counter; 58 static int dev_tools_agent_counter;
58 routing_id_ = ++dev_tools_agent_counter; 59 routing_id_ = ++dev_tools_agent_counter;
59 if (routing_id_ == 1) 60 if (routing_id_ == 1)
60 WebDevToolsAgent::setMessageLoopDispatchHandler( 61 WebDevToolsAgent::setMessageLoopDispatchHandler(
61 &TestShellDevToolsAgent::DispatchMessageLoop); 62 &TestShellDevToolsAgent::DispatchMessageLoop);
62 } 63 }
63 64
64 TestShellDevToolsAgent::~TestShellDevToolsAgent() { 65 TestShellDevToolsAgent::~TestShellDevToolsAgent() {
65 } 66 }
(...skipping 17 matching lines...) Expand all
83 const WebKit::WebString& value) { 84 const WebKit::WebString& value) {
84 // TODO: Implement. 85 // TODO: Implement.
85 } 86 }
86 87
87 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* 88 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop*
88 TestShellDevToolsAgent::createClientMessageLoop() { 89 TestShellDevToolsAgent::createClientMessageLoop() {
89 return new WebKitClientMessageLoopImpl(); 90 return new WebKitClientMessageLoopImpl();
90 } 91 }
91 92
92 void TestShellDevToolsAgent::AsyncCall(const TestShellDevToolsCallArgs &args) { 93 void TestShellDevToolsAgent::AsyncCall(const TestShellDevToolsCallArgs &args) {
93 MessageLoop::current()->PostDelayedTask( 94 MessageLoop::current()->PostTask(
94 FROM_HERE, 95 FROM_HERE,
95 call_method_factory_.NewRunnableMethod(&TestShellDevToolsAgent::Call, 96 base::Bind(&TestShellDevToolsAgent::Call, weak_factory_.GetWeakPtr(),
96 args), 97 args));
97 0);
98 } 98 }
99 99
100 void TestShellDevToolsAgent::Call(const TestShellDevToolsCallArgs &args) { 100 void TestShellDevToolsAgent::Call(const TestShellDevToolsCallArgs &args) {
101 WebDevToolsAgent* web_agent = GetWebAgent(); 101 WebDevToolsAgent* web_agent = GetWebAgent();
102 if (web_agent) 102 if (web_agent)
103 web_agent->dispatchOnInspectorBackend(args.data_); 103 web_agent->dispatchOnInspectorBackend(args.data_);
104 if (TestShellDevToolsCallArgs::calls_count() == 1 && dev_tools_client_) 104 if (TestShellDevToolsCallArgs::calls_count() == 1 && dev_tools_client_)
105 dev_tools_client_->all_messages_processed(); 105 dev_tools_client_->all_messages_processed();
106 } 106 }
107 107
(...skipping 19 matching lines...) Expand all
127 127
128 void TestShellDevToolsAgent::detach() { 128 void TestShellDevToolsAgent::detach() {
129 DCHECK(dev_tools_client_); 129 DCHECK(dev_tools_client_);
130 WebDevToolsAgent* web_agent = GetWebAgent(); 130 WebDevToolsAgent* web_agent = GetWebAgent();
131 if (web_agent) 131 if (web_agent)
132 web_agent->detach(); 132 web_agent->detach();
133 dev_tools_client_ = NULL; 133 dev_tools_client_ = NULL;
134 } 134 }
135 135
136 void TestShellDevToolsAgent::frontendLoaded() { 136 void TestShellDevToolsAgent::frontendLoaded() {
137 MessageLoop::current()->PostDelayedTask( 137 MessageLoop::current()->PostTask(
138 FROM_HERE, 138 FROM_HERE,
139 call_method_factory_.NewRunnableMethod( 139 base::Bind(&TestShellDevToolsAgent::DelayedFrontendLoaded,
140 &TestShellDevToolsAgent::DelayedFrontendLoaded), 140 weak_factory_.GetWeakPtr()));
141 0);
142 } 141 }
143 142
144 bool TestShellDevToolsAgent::evaluateInWebInspector( 143 bool TestShellDevToolsAgent::evaluateInWebInspector(
145 long call_id, 144 long call_id,
146 const std::string& script) { 145 const std::string& script) {
147 WebDevToolsAgent* agent = GetWebAgent(); 146 WebDevToolsAgent* agent = GetWebAgent();
148 if (!agent) 147 if (!agent)
149 return false; 148 return false;
150 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); 149 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script));
151 return true; 150 return true;
152 } 151 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_devtools_agent.h ('k') | webkit/tools/test_shell/test_shell_devtools_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698