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

Side by Side Diff: mojo/shell/content_handler_connection.cc

Issue 1311353005: Adds a way to determine id of content handler that created app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nuke comment Created 5 years, 3 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
« no previous file with comments | « mojo/shell/content_handler_connection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/content_handler_connection.h" 5 #include "mojo/shell/content_handler_connection.h"
6 6
7 #include "mojo/shell/application_manager.h" 7 #include "mojo/shell/application_manager.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace shell { 10 namespace shell {
11 11
12 ContentHandlerConnection::ContentHandlerConnection( 12 ContentHandlerConnection::ContentHandlerConnection(
13 ApplicationInstance* originator, 13 ApplicationInstance* originator,
14 ApplicationManager* manager, 14 ApplicationManager* manager,
15 const GURL& content_handler_url, 15 const GURL& content_handler_url,
16 const GURL& requestor_url, 16 const GURL& requestor_url,
17 const std::string& qualifier, 17 const std::string& qualifier,
18 const CapabilityFilter& filter) 18 const CapabilityFilter& filter,
19 uint32_t id)
19 : manager_(manager), 20 : manager_(manager),
20 content_handler_url_(content_handler_url), 21 content_handler_url_(content_handler_url),
21 content_handler_qualifier_(qualifier), 22 content_handler_qualifier_(qualifier),
22 connection_closed_(false) { 23 connection_closed_(false),
24 id_(id) {
23 ServiceProviderPtr services; 25 ServiceProviderPtr services;
24 mojo::URLRequestPtr request(mojo::URLRequest::New()); 26 mojo::URLRequestPtr request(mojo::URLRequest::New());
25 request->url = mojo::String::From(content_handler_url.spec()); 27 request->url = mojo::String::From(content_handler_url.spec());
26 manager->ConnectToApplication( 28 manager->ConnectToApplication(
27 originator, request.Pass(), qualifier, requestor_url, GetProxy(&services), 29 originator, request.Pass(), qualifier, requestor_url, GetProxy(&services),
28 nullptr, filter, base::Closure()); 30 nullptr, filter, base::Closure(), EmptyConnectCallback());
29 MessagePipe pipe; 31 MessagePipe pipe;
30 content_handler_.Bind( 32 content_handler_.Bind(
31 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); 33 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
32 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); 34 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
33 content_handler_.set_connection_error_handler( 35 content_handler_.set_connection_error_handler(
34 [this]() { CloseConnection(); }); 36 [this]() { CloseConnection(); });
35 } 37 }
36 38
37 void ContentHandlerConnection::CloseConnection() { 39 void ContentHandlerConnection::CloseConnection() {
38 if (connection_closed_) 40 if (connection_closed_)
39 return; 41 return;
40 connection_closed_ = true; 42 connection_closed_ = true;
41 manager_->OnContentHandlerConnectionClosed(this); 43 manager_->OnContentHandlerConnectionClosed(this);
42 delete this; 44 delete this;
43 } 45 }
44 46
45 ContentHandlerConnection::~ContentHandlerConnection() { 47 ContentHandlerConnection::~ContentHandlerConnection() {
46 // If this DCHECK fails then something has tried to delete this object without 48 // If this DCHECK fails then something has tried to delete this object without
47 // calling CloseConnection. 49 // calling CloseConnection.
48 DCHECK(connection_closed_); 50 DCHECK(connection_closed_);
49 } 51 }
50 52
51 } // namespace shell 53 } // namespace shell
52 } // namespace mojo 54 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/content_handler_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698