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

Unified Diff: mojo/service_manager/service_manager.cc

Issue 256133002: Changes view manager test to connect via shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to trunk Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: mojo/service_manager/service_manager.cc
diff --git a/mojo/service_manager/service_manager.cc b/mojo/service_manager/service_manager.cc
index c34e83f55acea9fe2017cc8fb5a86ddb13f1f0bf..b62c6e14b012f187c98247ac5a471c94a46fa4df 100644
--- a/mojo/service_manager/service_manager.cc
+++ b/mojo/service_manager/service_manager.cc
@@ -58,14 +58,59 @@ class ServiceManager::ServiceFactory : public Shell, public ErrorHandler {
ServiceManager* const manager_;
const GURL url_;
RemotePtr<ShellClient> shell_client_;
+
DISALLOW_COPY_AND_ASSIGN(ServiceFactory);
};
+class ServiceManager::TestAPI::TestShellConnection
+ : public Shell,
+ public ErrorHandler {
+ public:
+ explicit TestShellConnection(ServiceManager* manager) : manager_(manager) {
+ InterfacePipe<Shell> pipe;
+ shell_client_.reset(pipe.handle_to_peer.Pass(), this, this);
+ shell_handle_ = pipe.handle_to_self.Pass();
+ }
+ virtual ~TestShellConnection() {}
+
+ ScopedShellHandle GetShellHandle() {
+ return shell_handle_.Pass();
+ }
+
+ // Shell:
+ virtual void Connect(const String& url,
+ ScopedMessagePipeHandle client_pipe) OVERRIDE {
+ manager_->Connect(GURL(url.To<std::string>()), client_pipe.Pass());
+ }
+
+ virtual void OnError() OVERRIDE {
+ }
+
+ private:
+ ServiceManager* manager_;
+ RemotePtr<ShellClient> shell_client_;
+ ScopedShellHandle shell_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestShellConnection);
+};
+
// static
+ServiceManager::TestAPI::TestAPI(ServiceManager* manager) : manager_(manager) {
+}
+
+ServiceManager::TestAPI::~TestAPI() {
+}
+
bool ServiceManager::TestAPI::HasCreatedInstance() {
return has_created_instance;
}
+ScopedShellHandle ServiceManager::TestAPI::GetShellHandle() {
+ if (!shell_connection_.get())
+ shell_connection_.reset(new TestShellConnection(manager_));
+ return shell_connection_->GetShellHandle().Pass();
+}
+
bool ServiceManager::TestAPI::HasFactoryForURL(const GURL& url) const {
return manager_->url_to_service_factory_.find(url) !=
manager_->url_to_service_factory_.end();
« no previous file with comments | « mojo/service_manager/service_manager.h ('k') | mojo/services/view_manager/view_manager_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698