OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 DISALLOW_COPY_AND_ASSIGN(BrowserTargetImpl); | 75 DISALLOW_COPY_AND_ASSIGN(BrowserTargetImpl); |
76 }; | 76 }; |
77 | 77 |
78 class PingBrowserTargetImpl : public BrowserTargetImpl { | 78 class PingBrowserTargetImpl : public BrowserTargetImpl { |
79 public: | 79 public: |
80 explicit PingBrowserTargetImpl(base::RunLoop* run_loop) | 80 explicit PingBrowserTargetImpl(base::RunLoop* run_loop) |
81 : BrowserTargetImpl(run_loop) {} | 81 : BrowserTargetImpl(run_loop) {} |
82 | 82 |
83 ~PingBrowserTargetImpl() override {} | 83 ~PingBrowserTargetImpl() override {} |
84 | 84 |
| 85 // mojo::InterfaceImpl<BrowserTarget> overrides: |
| 86 void OnConnectionEstablished() override { client()->Ping(); } |
| 87 |
85 // Quit the RunLoop when called. | 88 // Quit the RunLoop when called. |
86 void PingResponse() override { | 89 void PingResponse() override { |
87 got_message = true; | 90 got_message = true; |
88 run_loop_->Quit(); | 91 run_loop_->Quit(); |
89 } | 92 } |
90 | 93 |
91 private: | 94 private: |
92 DISALLOW_COPY_AND_ASSIGN(PingBrowserTargetImpl); | 95 DISALLOW_COPY_AND_ASSIGN(PingBrowserTargetImpl); |
93 }; | 96 }; |
94 | 97 |
(...skipping 29 matching lines...) Expand all Loading... |
124 // WebUIController overrides: | 127 // WebUIController overrides: |
125 void RenderViewCreated(RenderViewHost* render_view_host) override { | 128 void RenderViewCreated(RenderViewHost* render_view_host) override { |
126 render_view_host->GetMainFrame()->GetServiceRegistry()-> | 129 render_view_host->GetMainFrame()->GetServiceRegistry()-> |
127 AddService<BrowserTarget>(base::Bind( | 130 AddService<BrowserTarget>(base::Bind( |
128 &PingTestWebUIController::CreateHandler, base::Unretained(this))); | 131 &PingTestWebUIController::CreateHandler, base::Unretained(this))); |
129 } | 132 } |
130 | 133 |
131 void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { | 134 void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { |
132 browser_target_.reset(mojo::WeakBindToRequest( | 135 browser_target_.reset(mojo::WeakBindToRequest( |
133 new PingBrowserTargetImpl(run_loop_), &request)); | 136 new PingBrowserTargetImpl(run_loop_), &request)); |
134 browser_target_->client()->Ping(); | |
135 } | 137 } |
136 | 138 |
137 private: | 139 private: |
138 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController); | 140 DISALLOW_COPY_AND_ASSIGN(PingTestWebUIController); |
139 }; | 141 }; |
140 | 142 |
141 // WebUIControllerFactory that creates TestWebUIController. | 143 // WebUIControllerFactory that creates TestWebUIController. |
142 class TestWebUIControllerFactory : public WebUIControllerFactory { | 144 class TestWebUIControllerFactory : public WebUIControllerFactory { |
143 public: | 145 public: |
144 TestWebUIControllerFactory() : run_loop_(NULL) {} | 146 TestWebUIControllerFactory() : run_loop_(NULL) {} |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 NavigateToURL(other_shell, test_url); | 224 NavigateToURL(other_shell, test_url); |
223 // RunLoop is quit when message received from page. | 225 // RunLoop is quit when message received from page. |
224 other_run_loop.Run(); | 226 other_run_loop.Run(); |
225 EXPECT_TRUE(got_message); | 227 EXPECT_TRUE(got_message); |
226 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), | 228 EXPECT_EQ(shell()->web_contents()->GetRenderProcessHost(), |
227 other_shell->web_contents()->GetRenderProcessHost()); | 229 other_shell->web_contents()->GetRenderProcessHost()); |
228 } | 230 } |
229 | 231 |
230 } // namespace | 232 } // namespace |
231 } // namespace content | 233 } // namespace content |
OLD | NEW |