Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: mojo/service_manager/service_manager_unittest.cc

Issue 423963004: First cut at "content handling" support in Mojo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more gn Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/service_manager/service_manager.cc ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (context_) 111 if (context_)
112 ++context_->num_loader_deletes; 112 ++context_->num_loader_deletes;
113 test_app_.reset(NULL); 113 test_app_.reset(NULL);
114 } 114 }
115 115
116 void set_context(TestContext* context) { context_ = context; } 116 void set_context(TestContext* context) { context_ = context; }
117 int num_loads() const { return num_loads_; } 117 int num_loads() const { return num_loads_; }
118 118
119 private: 119 private:
120 // ServiceLoader implementation. 120 // ServiceLoader implementation.
121 virtual void LoadService( 121 virtual void Load(ServiceManager* manager,
122 ServiceManager* manager, 122 const GURL& url,
123 const GURL& url, 123 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE {
124 ScopedMessagePipeHandle service_provider_handle) OVERRIDE {
125 ++num_loads_; 124 ++num_loads_;
126 test_app_.reset(new ApplicationImpl(this, service_provider_handle.Pass())); 125 test_app_.reset(
126 new ApplicationImpl(this, callbacks->RegisterApplication().Pass()));
127 } 127 }
128 128
129 virtual void OnServiceError(ServiceManager* manager, 129 virtual void OnServiceError(ServiceManager* manager,
130 const GURL& url) OVERRIDE { 130 const GURL& url) OVERRIDE {
131 } 131 }
132 132
133 // ApplicationDelegate implementation. 133 // ApplicationDelegate implementation.
134 virtual bool ConfigureIncomingConnection( 134 virtual bool ConfigureIncomingConnection(
135 ApplicationConnection* connection) OVERRIDE { 135 ApplicationConnection* connection) OVERRIDE {
136 connection->AddService(this); 136 connection->AddService(this);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 public InterfaceFactory<TestA>, 325 public InterfaceFactory<TestA>,
326 public InterfaceFactory<TestB>, 326 public InterfaceFactory<TestB>,
327 public InterfaceFactory<TestC> { 327 public InterfaceFactory<TestC> {
328 public: 328 public:
329 Tester(TesterContext* context, const std::string& requestor_url) 329 Tester(TesterContext* context, const std::string& requestor_url)
330 : context_(context), 330 : context_(context),
331 requestor_url_(requestor_url) {} 331 requestor_url_(requestor_url) {}
332 virtual ~Tester() {} 332 virtual ~Tester() {}
333 333
334 private: 334 private:
335 virtual void LoadService( 335 virtual void Load(ServiceManager* manager,
336 ServiceManager* manager, 336 const GURL& url,
337 const GURL& url, 337 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE {
338 ScopedMessagePipeHandle shell_handle) OVERRIDE { 338 app_.reset(
339 app_.reset(new ApplicationImpl(this, shell_handle.Pass())); 339 new ApplicationImpl(this, callbacks->RegisterApplication().Pass()));
340 } 340 }
341 341
342 virtual void OnServiceError(ServiceManager* manager, 342 virtual void OnServiceError(ServiceManager* manager,
343 const GURL& url) OVERRIDE {} 343 const GURL& url) OVERRIDE {}
344 344
345 virtual bool ConfigureIncomingConnection( 345 virtual bool ConfigureIncomingConnection(
346 ApplicationConnection* connection) OVERRIDE { 346 ApplicationConnection* connection) OVERRIDE {
347 if (!requestor_url_.empty() && 347 if (!requestor_url_.empty() &&
348 requestor_url_ != connection->GetRemoteApplicationURL()) { 348 requestor_url_ != connection->GetRemoteApplicationURL()) {
349 context_->set_tester_called_quit(); 349 context_->set_tester_called_quit();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 std::string url("test:test3"); 641 std::string url("test:test3");
642 TestServicePtr test_service; 642 TestServicePtr test_service;
643 service_manager_->ConnectToService(GURL(url), &test_service); 643 service_manager_->ConnectToService(GURL(url), &test_service);
644 644
645 EXPECT_EQ(1, interceptor.call_count()); 645 EXPECT_EQ(1, interceptor.call_count());
646 EXPECT_EQ(url, interceptor.url_spec()); 646 EXPECT_EQ(url, interceptor.url_spec());
647 EXPECT_EQ(1, default_loader->num_loads()); 647 EXPECT_EQ(1, default_loader->num_loads());
648 } 648 }
649 649
650 } // namespace mojo 650 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/service_manager/service_manager.cc ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698