Chromium Code Reviews| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 // static | 277 // static |
| 278 ViewManagerProxy* ViewManagerProxy::instance_ = NULL; | 278 ViewManagerProxy* ViewManagerProxy::instance_ = NULL; |
| 279 | 279 |
| 280 // static | 280 // static |
| 281 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; | 281 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; |
| 282 | 282 |
| 283 // static | 283 // static |
| 284 bool ViewManagerProxy::in_embed_ = false; | 284 bool ViewManagerProxy::in_embed_ = false; |
| 285 | 285 |
| 286 class TestViewManagerClientConnection | 286 class TestViewManagerClientConnection |
| 287 : public InterfaceImpl<ViewManagerClient> { | 287 : public InterfaceImplDeleteOnError<ViewManagerClient> { |
| 288 public: | 288 public: |
| 289 TestViewManagerClientConnection(ApplicationConnection* app_connection) : | 289 TestViewManagerClientConnection() : connection_(&tracker_) { |
| 290 connection_(&tracker_) { | |
| 291 tracker_.set_delegate(&connection_); | 290 tracker_.set_delegate(&connection_); |
| 292 } | 291 } |
| 293 | 292 |
| 294 // InterfaceImp: | 293 // InterfaceImp: |
| 295 virtual void OnConnectionEstablished() OVERRIDE { | 294 virtual void OnConnectionEstablished() OVERRIDE { |
| 296 connection_.set_router(internal_state()->router()); | 295 connection_.set_router(internal_state()->router()); |
| 297 connection_.set_view_manager(client()); | 296 connection_.set_view_manager(client()); |
| 298 } | 297 } |
| 299 | 298 |
| 300 // ViewMangerClient: | 299 // ViewMangerClient: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 | 356 |
| 358 private: | 357 private: |
| 359 TestChangeTracker tracker_; | 358 TestChangeTracker tracker_; |
| 360 ViewManagerProxy connection_; | 359 ViewManagerProxy connection_; |
| 361 | 360 |
| 362 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 361 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
| 363 }; | 362 }; |
| 364 | 363 |
| 365 // Used with ViewManagerService::Embed(). Creates a | 364 // Used with ViewManagerService::Embed(). Creates a |
| 366 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. | 365 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. |
| 367 class EmbedServiceLoader : public ServiceLoader, ApplicationDelegate { | 366 class EmbedServiceLoader |
| 367 : public ServiceLoader, | |
| 368 ApplicationDelegate, | |
| 369 public DefaultInterfaceProvider<TestViewManagerClientConnection, | |
|
jamesr
2014/07/11 20:07:10
the EmbedServiceLoader just wants to allocate+bind
| |
| 370 ViewManagerClient> { | |
| 368 public: | 371 public: |
| 369 EmbedServiceLoader() {} | 372 EmbedServiceLoader() {} |
| 370 virtual ~EmbedServiceLoader() {} | 373 virtual ~EmbedServiceLoader() {} |
| 371 | 374 |
| 372 // ServiceLoader: | 375 // ServiceLoader: |
| 373 virtual void LoadService(ServiceManager* manager, | 376 virtual void LoadService(ServiceManager* manager, |
| 374 const GURL& url, | 377 const GURL& url, |
| 375 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 378 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
| 376 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, | 379 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, |
| 377 shell_handle.Pass())); | 380 shell_handle.Pass())); |
| 378 apps_.push_back(app.release()); | 381 apps_.push_back(app.release()); |
| 379 } | 382 } |
| 380 virtual void OnServiceError(ServiceManager* manager, | 383 virtual void OnServiceError(ServiceManager* manager, |
| 381 const GURL& url) OVERRIDE { | 384 const GURL& url) OVERRIDE { |
| 382 } | 385 } |
| 383 | 386 |
| 384 // ApplicationDelegate | 387 // ApplicationDelegate |
| 385 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 388 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 386 OVERRIDE { | 389 OVERRIDE { |
| 387 connection->AddService<TestViewManagerClientConnection>(); | 390 connection->AddServiceProvider(this); |
| 388 return true; | 391 return true; |
| 389 } | 392 } |
| 390 | 393 |
| 391 private: | 394 private: |
| 392 ScopedVector<ApplicationImpl> apps_; | 395 ScopedVector<ApplicationImpl> apps_; |
| 393 | 396 |
| 394 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); | 397 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); |
| 395 }; | 398 }; |
| 396 | 399 |
| 397 // Creates an id used for transport from the specified parameters. | 400 // Creates an id used for transport from the specified parameters. |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1376 // originating connection. | 1379 // originating connection. |
| 1377 | 1380 |
| 1378 // TODO(beng): Add tests for focus: | 1381 // TODO(beng): Add tests for focus: |
| 1379 // - focus between two nodes known to a connection | 1382 // - focus between two nodes known to a connection |
| 1380 // - focus between nodes unknown to one of the connections. | 1383 // - focus between nodes unknown to one of the connections. |
| 1381 // - focus between nodes unknown to either connection. | 1384 // - focus between nodes unknown to either connection. |
| 1382 | 1385 |
| 1383 } // namespace service | 1386 } // namespace service |
| 1384 } // namespace view_manager | 1387 } // namespace view_manager |
| 1385 } // namespace mojo | 1388 } // namespace mojo |
| OLD | NEW |