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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 // static | 298 // static |
299 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; | 299 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; |
300 | 300 |
301 // static | 301 // static |
302 bool ViewManagerProxy::in_embed_ = false; | 302 bool ViewManagerProxy::in_embed_ = false; |
303 | 303 |
304 class TestViewManagerClientConnection | 304 class TestViewManagerClientConnection |
305 : public InterfaceImpl<ViewManagerClient> { | 305 : public InterfaceImpl<ViewManagerClient> { |
306 public: | 306 public: |
307 TestViewManagerClientConnection(ApplicationConnection* app_connection) : | 307 TestViewManagerClientConnection() : connection_(&tracker_) { |
308 connection_(&tracker_) { | |
309 tracker_.set_delegate(&connection_); | 308 tracker_.set_delegate(&connection_); |
310 } | 309 } |
311 | 310 |
312 // InterfaceImp: | 311 // InterfaceImp: |
313 virtual void OnConnectionEstablished() OVERRIDE { | 312 virtual void OnConnectionEstablished() OVERRIDE { |
314 connection_.set_router(internal_state()->router()); | 313 connection_.set_router(internal_state()->router()); |
315 connection_.set_view_manager(client()); | 314 connection_.set_view_manager(client()); |
316 } | 315 } |
317 | 316 |
318 // ViewMangerClient: | 317 // ViewMangerClient: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 374 |
376 private: | 375 private: |
377 TestChangeTracker tracker_; | 376 TestChangeTracker tracker_; |
378 ViewManagerProxy connection_; | 377 ViewManagerProxy connection_; |
379 | 378 |
380 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 379 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
381 }; | 380 }; |
382 | 381 |
383 // Used with ViewManagerService::Embed(). Creates a | 382 // Used with ViewManagerService::Embed(). Creates a |
384 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. | 383 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. |
385 class EmbedServiceLoader : public ServiceLoader, ApplicationDelegate { | 384 class EmbedServiceLoader : public ServiceLoader, |
| 385 ApplicationDelegate, |
| 386 public InterfaceFactory<ViewManagerClient> { |
386 public: | 387 public: |
387 EmbedServiceLoader() {} | 388 EmbedServiceLoader() {} |
388 virtual ~EmbedServiceLoader() {} | 389 virtual ~EmbedServiceLoader() {} |
389 | 390 |
390 // ServiceLoader: | 391 // ServiceLoader implementation: |
391 virtual void LoadService(ServiceManager* manager, | 392 virtual void LoadService(ServiceManager* manager, |
392 const GURL& url, | 393 const GURL& url, |
393 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 394 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
394 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, | 395 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, |
395 shell_handle.Pass())); | 396 shell_handle.Pass())); |
396 apps_.push_back(app.release()); | 397 apps_.push_back(app.release()); |
397 } | 398 } |
398 virtual void OnServiceError(ServiceManager* manager, | 399 virtual void OnServiceError(ServiceManager* manager, |
399 const GURL& url) OVERRIDE { | 400 const GURL& url) OVERRIDE { |
400 } | 401 } |
401 | 402 |
402 // ApplicationDelegate | 403 // ApplicationDelegate implementation: |
403 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 404 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
404 OVERRIDE { | 405 OVERRIDE { |
405 connection->AddService<TestViewManagerClientConnection>(); | 406 connection->AddServiceFactory(this); |
406 return true; | 407 return true; |
407 } | 408 } |
408 | 409 |
| 410 // InterfaceFactory<ViewManagerClient> implementation: |
| 411 virtual void Create(ApplicationConnection* connection, |
| 412 InterfaceRequest<ViewManagerClient> request) OVERRIDE { |
| 413 mojo::BindToRequest(new TestViewManagerClientConnection, &request); |
| 414 } |
| 415 |
409 private: | 416 private: |
410 ScopedVector<ApplicationImpl> apps_; | 417 ScopedVector<ApplicationImpl> apps_; |
411 | 418 |
412 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); | 419 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); |
413 }; | 420 }; |
414 | 421 |
415 // Creates an id used for transport from the specified parameters. | 422 // Creates an id used for transport from the specified parameters. |
416 Id BuildNodeId(ConnectionSpecificId connection_id, | 423 Id BuildNodeId(ConnectionSpecificId connection_id, |
417 ConnectionSpecificId node_id) { | 424 ConnectionSpecificId node_id) { |
418 return (connection_id << 16) | node_id; | 425 return (connection_id << 16) | node_id; |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 // originating connection. | 1404 // originating connection. |
1398 | 1405 |
1399 // TODO(beng): Add tests for focus: | 1406 // TODO(beng): Add tests for focus: |
1400 // - focus between two nodes known to a connection | 1407 // - focus between two nodes known to a connection |
1401 // - focus between nodes unknown to one of the connections. | 1408 // - focus between nodes unknown to one of the connections. |
1402 // - focus between nodes unknown to either connection. | 1409 // - focus between nodes unknown to either connection. |
1403 | 1410 |
1404 } // namespace service | 1411 } // namespace service |
1405 } // namespace view_manager | 1412 } // namespace view_manager |
1406 } // namespace mojo | 1413 } // namespace mojo |
OLD | NEW |