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

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: Addressed Dave's comments, plus added a --content-handlers switch 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 LoadService(
122 ServiceManager* manager, 122 ServiceManager* manager,
123 const GURL& url, 123 const GURL& url,
124 ScopedMessagePipeHandle service_provider_handle) OVERRIDE { 124 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE {
125 ++num_loads_; 125 ++num_loads_;
126 test_app_.reset(new ApplicationImpl(this, service_provider_handle.Pass())); 126 test_app_.reset(
127 new ApplicationImpl(this, callbacks->RegisterApplication().Pass()));
127 } 128 }
128 129
129 virtual void OnServiceError(ServiceManager* manager, 130 virtual void OnServiceError(ServiceManager* manager,
130 const GURL& url) OVERRIDE { 131 const GURL& url) OVERRIDE {
131 } 132 }
132 133
133 // ApplicationDelegate implementation. 134 // ApplicationDelegate implementation.
134 virtual bool ConfigureIncomingConnection( 135 virtual bool ConfigureIncomingConnection(
135 ApplicationConnection* connection) OVERRIDE { 136 ApplicationConnection* connection) OVERRIDE {
136 connection->AddService(this); 137 connection->AddService(this);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 public: 322 public:
322 Tester(TesterContext* context, const std::string& requestor_url) 323 Tester(TesterContext* context, const std::string& requestor_url)
323 : context_(context), 324 : context_(context),
324 requestor_url_(requestor_url) {} 325 requestor_url_(requestor_url) {}
325 virtual ~Tester() {} 326 virtual ~Tester() {}
326 327
327 private: 328 private:
328 virtual void LoadService( 329 virtual void LoadService(
329 ServiceManager* manager, 330 ServiceManager* manager,
330 const GURL& url, 331 const GURL& url,
331 ScopedMessagePipeHandle shell_handle) OVERRIDE { 332 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE {
332 app_.reset(new ApplicationImpl(this, shell_handle.Pass())); 333 app_.reset(
334 new ApplicationImpl(this, callbacks->RegisterApplication().Pass()));
333 } 335 }
334 336
335 virtual void OnServiceError(ServiceManager* manager, 337 virtual void OnServiceError(ServiceManager* manager,
336 const GURL& url) OVERRIDE {} 338 const GURL& url) OVERRIDE {}
337 339
338 virtual bool ConfigureIncomingConnection( 340 virtual bool ConfigureIncomingConnection(
339 ApplicationConnection* connection) OVERRIDE { 341 ApplicationConnection* connection) OVERRIDE {
340 if (!requestor_url_.empty() && 342 if (!requestor_url_.empty() &&
341 requestor_url_ != connection->GetRemoteApplicationURL()) { 343 requestor_url_ != connection->GetRemoteApplicationURL()) {
342 context_->set_tester_called_quit(); 344 context_->set_tester_called_quit();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 std::string url("test:test3"); 627 std::string url("test:test3");
626 TestServicePtr test_service; 628 TestServicePtr test_service;
627 service_manager_->ConnectToService(GURL(url), &test_service); 629 service_manager_->ConnectToService(GURL(url), &test_service);
628 630
629 EXPECT_EQ(1, interceptor.call_count()); 631 EXPECT_EQ(1, interceptor.call_count());
630 EXPECT_EQ(url, interceptor.url_spec()); 632 EXPECT_EQ(url, interceptor.url_spec());
631 EXPECT_EQ(1, default_loader->num_loads()); 633 EXPECT_EQ(1, default_loader->num_loads());
632 } 634 }
633 635
634 } // namespace mojo 636 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698