Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/shell/content_handler_connection.h" | |
| 6 | |
| 7 #include "mojo/shell/application_manager.h" | |
| 8 | |
| 9 namespace mojo { | |
| 10 namespace shell { | |
| 11 | |
| 12 ContentHandlerConnection::ContentHandlerConnection( | |
| 13 ApplicationManager* manager, | |
| 14 const GURL& content_handler_url, | |
| 15 const GURL& requestor_url, | |
| 16 const std::string& qualifier) | |
| 17 : manager_(manager), | |
| 18 content_handler_url_(content_handler_url), | |
| 19 content_handler_qualifier_(qualifier), | |
| 20 connection_closed_(false) { | |
| 21 ServiceProviderPtr services; | |
| 22 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
| 23 request->url = mojo::String::From(content_handler_url.spec()); | |
| 24 manager->ConnectToApplicationInternal( | |
|
Fady Samuel
2015/07/09 17:52:47
Actually, it needs to be friend for this call.
jam
2015/07/09 18:00:18
if we don't want to make it public, can we call th
Fady Samuel
2015/07/09 18:15:17
Done.
| |
| 25 request.Pass(), qualifier, requestor_url, GetProxy(&services), | |
| 26 nullptr, base::Closure()); | |
| 27 MessagePipe pipe; | |
| 28 content_handler_.Bind( | |
| 29 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); | |
| 30 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); | |
| 31 content_handler_.set_error_handler(this); | |
| 32 } | |
| 33 | |
| 34 void ContentHandlerConnection::CloseConnection() { | |
| 35 if (connection_closed_) | |
| 36 return; | |
| 37 connection_closed_ = true; | |
| 38 manager_->OnContentHandlerConnectionClosed(this); | |
| 39 delete this; | |
| 40 } | |
| 41 | |
| 42 ContentHandlerConnection::~ContentHandlerConnection() { | |
| 43 // If this DCHECK fails then something has tried to delete this object without | |
| 44 // calling CloseConnection. | |
| 45 DCHECK(connection_closed_); | |
| 46 } | |
| 47 | |
| 48 void ContentHandlerConnection::OnConnectionError() { | |
| 49 CloseConnection(); | |
| 50 } | |
| 51 | |
| 52 } // namespace shell | |
| 53 } // namespace mojo | |
| OLD | NEW |