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

Side by Side Diff: webkit/tools/test_shell/test_shell_devtools_client.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" 5 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
6 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontend.h " 6 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontend.h "
7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 7 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
11 11
12 #undef LOG 12 #undef LOG
13 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" 13 #include "webkit/tools/test_shell/test_shell_devtools_agent.h"
14 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h" 14 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h"
15 #include "webkit/tools/test_shell/test_shell_devtools_client.h" 15 #include "webkit/tools/test_shell/test_shell_devtools_client.h"
16 16
17 #include "base/bind.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "base/message_loop.h" 19 #include "base/message_loop.h"
19 20
20 using WebKit::WebDevToolsAgent; 21 using WebKit::WebDevToolsAgent;
21 using WebKit::WebDevToolsFrontend; 22 using WebKit::WebDevToolsFrontend;
22 using WebKit::WebDevToolsMessageData; 23 using WebKit::WebDevToolsMessageData;
23 using WebKit::WebString; 24 using WebKit::WebString;
24 using WebKit::WebView; 25 using WebKit::WebView;
25 26
26 TestShellDevToolsClient::TestShellDevToolsClient(TestShellDevToolsAgent *agent, 27 TestShellDevToolsClient::TestShellDevToolsClient(TestShellDevToolsAgent *agent,
27 WebView* web_view) 28 WebView* web_view)
28 : ALLOW_THIS_IN_INITIALIZER_LIST(call_method_factory_(this)), 29 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
29 dev_tools_agent_(agent), 30 dev_tools_agent_(agent),
30 web_view_(web_view) { 31 web_view_(web_view) {
31 web_tools_frontend_.reset(WebDevToolsFrontend::create(web_view_, this, 32 web_tools_frontend_.reset(WebDevToolsFrontend::create(web_view_, this,
32 WebString::fromUTF8("en-US"))); 33 WebString::fromUTF8("en-US")));
33 dev_tools_agent_->attach(this); 34 dev_tools_agent_->attach(this);
34 } 35 }
35 36
36 TestShellDevToolsClient::~TestShellDevToolsClient() { 37 TestShellDevToolsClient::~TestShellDevToolsClient() {
37 // It is a chance that page will be destroyed at detach step of 38 // It is a chance that page will be destroyed at detach step of
38 // dev_tools_agent_ and we should clean pending requests a bit earlier. 39 // dev_tools_agent_ and we should clean pending requests a bit earlier.
39 call_method_factory_.RevokeAll(); 40 weak_factory_.InvalidateWeakPtrs();
40 if (dev_tools_agent_) 41 if (dev_tools_agent_)
41 dev_tools_agent_->detach(); 42 dev_tools_agent_->detach();
42 } 43 }
43 44
44 void TestShellDevToolsClient::sendFrontendLoaded() { 45 void TestShellDevToolsClient::sendFrontendLoaded() {
45 if (dev_tools_agent_) 46 if (dev_tools_agent_)
46 dev_tools_agent_->frontendLoaded(); 47 dev_tools_agent_->frontendLoaded();
47 } 48 }
48 49
49 void TestShellDevToolsClient::sendMessageToBackend( 50 void TestShellDevToolsClient::sendMessageToBackend(
(...skipping 17 matching lines...) Expand all
67 68
68 void TestShellDevToolsClient::dockWindow() { 69 void TestShellDevToolsClient::dockWindow() {
69 NOTIMPLEMENTED(); 70 NOTIMPLEMENTED();
70 } 71 }
71 72
72 void TestShellDevToolsClient::undockWindow() { 73 void TestShellDevToolsClient::undockWindow() {
73 NOTIMPLEMENTED(); 74 NOTIMPLEMENTED();
74 } 75 }
75 76
76 void TestShellDevToolsClient::AsyncCall(const TestShellDevToolsCallArgs &args) { 77 void TestShellDevToolsClient::AsyncCall(const TestShellDevToolsCallArgs &args) {
77 MessageLoop::current()->PostDelayedTask(FROM_HERE, 78 MessageLoop::current()->PostTask(
78 call_method_factory_.NewRunnableMethod(&TestShellDevToolsClient::Call, 79 FROM_HERE,
79 args), 0); 80 base::Bind(&TestShellDevToolsClient::Call, weak_factory_.GetWeakPtr(),
81 args));
80 } 82 }
81 83
82 void TestShellDevToolsClient::Call(const TestShellDevToolsCallArgs &args) { 84 void TestShellDevToolsClient::Call(const TestShellDevToolsCallArgs &args) {
83 web_tools_frontend_->dispatchOnInspectorFrontend(args.data_); 85 web_tools_frontend_->dispatchOnInspectorFrontend(args.data_);
84 if (TestShellDevToolsCallArgs::calls_count() == 1) 86 if (TestShellDevToolsCallArgs::calls_count() == 1)
85 all_messages_processed(); 87 all_messages_processed();
86 } 88 }
87 89
88 void TestShellDevToolsClient::all_messages_processed() { 90 void TestShellDevToolsClient::all_messages_processed() {
89 web_view_->mainFrame()->executeScript(WebKit::WebScriptSource( 91 web_view_->mainFrame()->executeScript(WebKit::WebScriptSource(
90 WebString::fromUTF8("if (window.WebInspector && " 92 WebString::fromUTF8("if (window.WebInspector && "
91 "WebInspector.queuesAreEmpty) WebInspector.queuesAreEmpty();"))); 93 "WebInspector.queuesAreEmpty) WebInspector.queuesAreEmpty();")));
92 } 94 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_devtools_client.h ('k') | webkit/tools/test_shell/test_webview_delegate_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698