OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/shell/service_manager.h" | 5 #include "mojo/shell/service_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/public/bindings/lib/remote_ptr.h" | 8 #include "mojo/public/bindings/lib/remote_ptr.h" |
9 #include "mojom/shell.h" | 9 #include "mojom/shell.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 namespace shell { | 12 namespace shell { |
13 | 13 |
14 class ServiceManager::Service : public ShellStub { | 14 class ServiceManager::Service : public Shell { |
15 public: | 15 public: |
16 Service(ServiceManager* manager, const GURL& url) | 16 Service(ServiceManager* manager, const GURL& url) |
17 : manager_(manager), | 17 : manager_(manager), |
18 url_(url) { | 18 url_(url) { |
19 MessagePipe pipe; | 19 MessagePipe pipe; |
20 shell_client_.reset(pipe.handle0.Pass()); | 20 shell_client_.reset(pipe.handle0.Pass(), this); |
21 shell_client_.SetPeer(this); | |
22 manager_->GetLoaderForURL(url)->Load(url, pipe.handle1.Pass()); | 21 manager_->GetLoaderForURL(url)->Load(url, pipe.handle1.Pass()); |
23 } | 22 } |
24 virtual ~Service() {} | 23 virtual ~Service() {} |
25 | 24 |
26 void ConnectToClient(ScopedMessagePipeHandle handle) { | 25 void ConnectToClient(ScopedMessagePipeHandle handle) { |
27 if (handle.is_valid()) | 26 if (handle.is_valid()) |
28 shell_client_->AcceptConnection(handle.Pass()); | 27 shell_client_->AcceptConnection(handle.Pass()); |
29 } | 28 } |
30 | 29 |
31 virtual void Connect(const String& url, | 30 virtual void Connect(const String& url, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 service = service_it->second; | 74 service = service_it->second; |
76 } else { | 75 } else { |
77 service = new Service(this, url); | 76 service = new Service(this, url); |
78 url_to_service_[url] = service; | 77 url_to_service_[url] = service; |
79 } | 78 } |
80 service->ConnectToClient(client_handle.Pass()); | 79 service->ConnectToClient(client_handle.Pass()); |
81 } | 80 } |
82 | 81 |
83 } // namespace shell | 82 } // namespace shell |
84 } // namespace mojo | 83 } // namespace mojo |
OLD | NEW |