OLD | NEW |
---|---|
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/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/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "grit/webkit_chromium_resources.h" | 9 #include "grit/webkit_chromium_resources.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
12 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h" | 12 #include "webkit/tools/test_shell/test_shell_devtools_callargs.h" |
13 #include "webkit/tools/test_shell/test_shell_devtools_client.h" | 13 #include "webkit/tools/test_shell/test_shell_devtools_client.h" |
14 #include "webkit/glue/webkit_glue.h" | 14 #include "webkit/glue/webkit_glue.h" |
15 | 15 |
16 using WebKit::WebCString; | 16 using WebKit::WebCString; |
17 using WebKit::WebDevToolsAgent; | 17 using WebKit::WebDevToolsAgent; |
18 using WebKit::WebDevToolsMessageData; | 18 using WebKit::WebDevToolsMessageData; |
19 using WebKit::WebString; | 19 using WebKit::WebString; |
20 using WebKit::WebView; | 20 using WebKit::WebView; |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 class WebKitClientMessageLoopImpl | 24 class WebKitClientMessageLoopImpl |
25 : public WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop { | 25 : public WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop { |
26 public: | 26 public: |
27 WebKitClientMessageLoopImpl() : message_loop_(MessageLoop::current()) { } | 27 WebKitClientMessageLoopImpl() : message_loop_(base::MessageLoop::current()) {} |
28 virtual ~WebKitClientMessageLoopImpl() { | 28 virtual ~WebKitClientMessageLoopImpl() { message_loop_ = NULL; } |
29 message_loop_ = NULL; | |
30 } | |
31 virtual void run() { | 29 virtual void run() { |
32 MessageLoop::ScopedNestableTaskAllower allow(message_loop_); | 30 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop_); |
33 message_loop_->Run(); | 31 message_loop_->Run(); |
34 } | 32 } |
35 virtual void quitNow() { | 33 virtual void quitNow() { |
36 message_loop_->QuitNow(); | 34 message_loop_->QuitNow(); |
37 } | 35 } |
38 private: | 36 private: |
39 MessageLoop* message_loop_; | 37 base::MessageLoop* message_loop_; |
40 }; | 38 }; |
41 | 39 |
42 } // namespace | 40 } // namespace |
43 | 41 |
44 TestShellDevToolsAgent::TestShellDevToolsAgent() | 42 TestShellDevToolsAgent::TestShellDevToolsAgent() |
45 : weak_factory_(this), | 43 : weak_factory_(this), |
46 dev_tools_client_(NULL) { | 44 dev_tools_client_(NULL) { |
47 static int dev_tools_agent_counter; | 45 static int dev_tools_agent_counter; |
48 routing_id_ = ++dev_tools_agent_counter; | 46 routing_id_ = ++dev_tools_agent_counter; |
49 } | 47 } |
(...skipping 20 matching lines...) Expand all Loading... | |
70 const WebKit::WebString& value) { | 68 const WebKit::WebString& value) { |
71 // TODO: Implement. | 69 // TODO: Implement. |
72 } | 70 } |
73 | 71 |
74 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* | 72 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* |
75 TestShellDevToolsAgent::createClientMessageLoop() { | 73 TestShellDevToolsAgent::createClientMessageLoop() { |
76 return new WebKitClientMessageLoopImpl(); | 74 return new WebKitClientMessageLoopImpl(); |
77 } | 75 } |
78 | 76 |
79 void TestShellDevToolsAgent::AsyncCall(const TestShellDevToolsCallArgs &args) { | 77 void TestShellDevToolsAgent::AsyncCall(const TestShellDevToolsCallArgs &args) { |
80 MessageLoop::current()->PostTask( | 78 base::MessageLoop::current()->PostTask( |
81 FROM_HERE, | 79 FROM_HERE, |
82 base::Bind(&TestShellDevToolsAgent::Call, weak_factory_.GetWeakPtr(), | 80 base::Bind( |
brettw
2013/05/06 17:43:33
I liked the old way better.
xhwang
2013/05/07 00:11:07
Done.
| |
83 args)); | 81 &TestShellDevToolsAgent::Call, weak_factory_.GetWeakPtr(), args)); |
84 } | 82 } |
85 | 83 |
86 void TestShellDevToolsAgent::Call(const TestShellDevToolsCallArgs &args) { | 84 void TestShellDevToolsAgent::Call(const TestShellDevToolsCallArgs &args) { |
87 WebDevToolsAgent* web_agent = GetWebAgent(); | 85 WebDevToolsAgent* web_agent = GetWebAgent(); |
88 if (web_agent) | 86 if (web_agent) |
89 web_agent->dispatchOnInspectorBackend(args.data_); | 87 web_agent->dispatchOnInspectorBackend(args.data_); |
90 if (TestShellDevToolsCallArgs::calls_count() == 1 && dev_tools_client_) | 88 if (TestShellDevToolsCallArgs::calls_count() == 1 && dev_tools_client_) |
91 dev_tools_client_->all_messages_processed(); | 89 dev_tools_client_->all_messages_processed(); |
92 } | 90 } |
93 | 91 |
(...skipping 21 matching lines...) Expand all Loading... | |
115 | 113 |
116 bool TestShellDevToolsAgent::evaluateInWebInspector( | 114 bool TestShellDevToolsAgent::evaluateInWebInspector( |
117 long call_id, | 115 long call_id, |
118 const std::string& script) { | 116 const std::string& script) { |
119 WebDevToolsAgent* agent = GetWebAgent(); | 117 WebDevToolsAgent* agent = GetWebAgent(); |
120 if (!agent) | 118 if (!agent) |
121 return false; | 119 return false; |
122 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); | 120 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); |
123 return true; | 121 return true; |
124 } | 122 } |
OLD | NEW |