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 : public ServiceLoader, |
| 367 ApplicationDelegate, |
| 368 public InterfaceProvider<ViewManagerClient> { |
368 public: | 369 public: |
369 EmbedServiceLoader() {} | 370 EmbedServiceLoader() {} |
370 virtual ~EmbedServiceLoader() {} | 371 virtual ~EmbedServiceLoader() {} |
371 | 372 |
372 // ServiceLoader: | 373 // ServiceLoader: |
373 virtual void LoadService(ServiceManager* manager, | 374 virtual void LoadService(ServiceManager* manager, |
374 const GURL& url, | 375 const GURL& url, |
375 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 376 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
376 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, | 377 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, |
377 shell_handle.Pass())); | 378 shell_handle.Pass())); |
378 apps_.push_back(app.release()); | 379 apps_.push_back(app.release()); |
379 } | 380 } |
380 virtual void OnServiceError(ServiceManager* manager, | 381 virtual void OnServiceError(ServiceManager* manager, |
381 const GURL& url) OVERRIDE { | 382 const GURL& url) OVERRIDE { |
382 } | 383 } |
383 | 384 |
384 // ApplicationDelegate | 385 // ApplicationDelegate |
385 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 386 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
386 OVERRIDE { | 387 OVERRIDE { |
387 connection->AddService<TestViewManagerClientConnection>(); | 388 connection->AddServiceProvider(this); |
388 return true; | 389 return true; |
389 } | 390 } |
390 | 391 |
| 392 // InterfaceProvider<ViewManagerClient> |
| 393 virtual void BindToRequest( |
| 394 ApplicationConnection* connection, |
| 395 InterfaceRequest<ViewManagerClient> request) OVERRIDE { |
| 396 mojo::BindToRequest(new TestViewManagerClientConnection, &request); |
| 397 } |
| 398 |
391 private: | 399 private: |
392 ScopedVector<ApplicationImpl> apps_; | 400 ScopedVector<ApplicationImpl> apps_; |
393 | 401 |
394 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); | 402 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); |
395 }; | 403 }; |
396 | 404 |
397 // Creates an id used for transport from the specified parameters. | 405 // Creates an id used for transport from the specified parameters. |
398 Id BuildNodeId(ConnectionSpecificId connection_id, | 406 Id BuildNodeId(ConnectionSpecificId connection_id, |
399 ConnectionSpecificId node_id) { | 407 ConnectionSpecificId node_id) { |
400 return (connection_id << 16) | node_id; | 408 return (connection_id << 16) | node_id; |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 // originating connection. | 1384 // originating connection. |
1377 | 1385 |
1378 // TODO(beng): Add tests for focus: | 1386 // TODO(beng): Add tests for focus: |
1379 // - focus between two nodes known to a connection | 1387 // - focus between two nodes known to a connection |
1380 // - focus between nodes unknown to one of the connections. | 1388 // - focus between nodes unknown to one of the connections. |
1381 // - focus between nodes unknown to either connection. | 1389 // - focus between nodes unknown to either connection. |
1382 | 1390 |
1383 } // namespace service | 1391 } // namespace service |
1384 } // namespace view_manager | 1392 } // namespace view_manager |
1385 } // namespace mojo | 1393 } // namespace mojo |
OLD | NEW |