Chromium Code Reviews| 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 #ifndef MOJO_PUBLIC_SHELL_SERVICE_H_ | 5 #ifndef MOJO_PUBLIC_SHELL_SERVICE_H_ |
| 6 #define MOJO_PUBLIC_SHELL_SERVICE_H_ | 6 #define MOJO_PUBLIC_SHELL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/public/bindings/error_handler.h" | 10 #include "mojo/public/bindings/error_handler.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 service_factory_ = service_factory; | 146 service_factory_ = service_factory; |
| 147 client_.reset( | 147 client_.reset( |
| 148 MakeScopedHandle( | 148 MakeScopedHandle( |
| 149 InterfaceHandle<typename ServiceInterface::_Peer>( | 149 InterfaceHandle<typename ServiceInterface::_Peer>( |
| 150 client_handle.release().value())).Pass(), | 150 client_handle.release().value())).Pass(), |
| 151 this, | 151 this, |
| 152 &reaper_); | 152 &reaper_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 Context* context() const { return service_factory_->context(); } | 155 Context* context() const { return service_factory_->context(); } |
| 156 Shell* GetShell() { return service_factory_->GetShell(); } | |
|
darin (slow to review)
2014/02/13 00:05:39
hmm, it'd be nice if GetShell() could just be shel
| |
| 156 typename ServiceInterface::_Peer* client() { return client_.get(); } | 157 typename ServiceInterface::_Peer* client() { return client_.get(); } |
| 157 | 158 |
| 158 private: | 159 private: |
| 159 // The Reaper class allows us to handle errors on the client proxy without | 160 // The Reaper class allows us to handle errors on the client proxy without |
| 160 // polluting the name space of the Service<> class. | 161 // polluting the name space of the Service<> class. |
| 161 class Reaper : public ErrorHandler { | 162 class Reaper : public ErrorHandler { |
| 162 public: | 163 public: |
| 163 Reaper(Service<ServiceInterface, ServiceImpl, Context>* service) | 164 Reaper(Service<ServiceInterface, ServiceImpl, Context>* service) |
| 164 : service_(service) {} | 165 : service_(service) {} |
| 165 virtual void OnError() { | 166 virtual void OnError() { |
| 166 service_->service_factory_->RemoveService( | 167 service_->service_factory_->RemoveService( |
| 167 static_cast<ServiceImpl*>(service_)); | 168 static_cast<ServiceImpl*>(service_)); |
| 168 } | 169 } |
| 169 private: | 170 private: |
| 170 Service<ServiceInterface, ServiceImpl, Context>* service_; | 171 Service<ServiceInterface, ServiceImpl, Context>* service_; |
| 171 }; | 172 }; |
| 172 friend class ServiceFactory<ServiceImpl, Context>; | 173 friend class ServiceFactory<ServiceImpl, Context>; |
| 173 Reaper reaper_; | 174 Reaper reaper_; |
| 174 ServiceFactory<ServiceImpl, Context>* service_factory_; | 175 ServiceFactory<ServiceImpl, Context>* service_factory_; |
| 175 RemotePtr<typename ServiceInterface::_Peer> client_; | 176 RemotePtr<typename ServiceInterface::_Peer> client_; |
| 176 }; | 177 }; |
| 177 | 178 |
| 178 } // namespace mojo | 179 } // namespace mojo |
| 179 | 180 |
| 180 #endif // MOJO_PUBLIC_SHELL_SERVICE_H_ | 181 #endif // MOJO_PUBLIC_SHELL_SERVICE_H_ |
| OLD | NEW |