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

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

Issue 1307273004: Group ConnectToApplication-related info into a params struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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') | mojo/shell/identity.h » ('j') | 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 "base/memory/scoped_ptr.h"
7 #include "mojo/shell/application_manager.h" 8 #include "mojo/shell/application_manager.h"
9 #include "mojo/shell/connect_to_application_params.h"
10 #include "mojo/shell/identity.h"
8 11
9 namespace mojo { 12 namespace mojo {
10 namespace shell { 13 namespace shell {
11 14
12 ContentHandlerConnection::ContentHandlerConnection( 15 ContentHandlerConnection::ContentHandlerConnection(
13 ApplicationInstance* originator,
14 ApplicationManager* manager, 16 ApplicationManager* manager,
17 const Identity& originator_identity,
18 const CapabilityFilter& originator_filter,
15 const GURL& content_handler_url, 19 const GURL& content_handler_url,
16 const GURL& requestor_url,
17 const std::string& qualifier, 20 const std::string& qualifier,
18 const CapabilityFilter& filter, 21 const CapabilityFilter& filter,
19 uint32_t id) 22 uint32_t id)
20 : manager_(manager), 23 : manager_(manager),
21 content_handler_url_(content_handler_url), 24 content_handler_url_(content_handler_url),
22 content_handler_qualifier_(qualifier), 25 content_handler_qualifier_(qualifier),
23 connection_closed_(false), 26 connection_closed_(false),
24 id_(id) { 27 id_(id) {
25 ServiceProviderPtr services; 28 ServiceProviderPtr services;
26 mojo::URLRequestPtr request(mojo::URLRequest::New()); 29
27 request->url = mojo::String::From(content_handler_url.spec()); 30 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
28 manager->ConnectToApplication( 31 params->set_originator_identity(originator_identity);
29 originator, request.Pass(), qualifier, requestor_url, GetProxy(&services), 32 params->set_originator_filter(originator_filter);
30 nullptr, filter, base::Closure(), EmptyConnectCallback()); 33 params->SetURLInfo(content_handler_url);
34 params->set_qualifier(qualifier);
35 params->set_services(GetProxy(&services));
36 params->set_filter(filter);
37
38 manager->ConnectToApplication(params.Pass());
39
31 MessagePipe pipe; 40 MessagePipe pipe;
32 content_handler_.Bind( 41 content_handler_.Bind(
33 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); 42 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
34 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); 43 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
35 content_handler_.set_connection_error_handler( 44 content_handler_.set_connection_error_handler(
36 [this]() { CloseConnection(); }); 45 [this]() { CloseConnection(); });
37 } 46 }
38 47
39 void ContentHandlerConnection::CloseConnection() { 48 void ContentHandlerConnection::CloseConnection() {
40 if (connection_closed_) 49 if (connection_closed_)
41 return; 50 return;
42 connection_closed_ = true; 51 connection_closed_ = true;
43 manager_->OnContentHandlerConnectionClosed(this); 52 manager_->OnContentHandlerConnectionClosed(this);
44 delete this; 53 delete this;
45 } 54 }
46 55
47 ContentHandlerConnection::~ContentHandlerConnection() { 56 ContentHandlerConnection::~ContentHandlerConnection() {
48 // If this DCHECK fails then something has tried to delete this object without 57 // If this DCHECK fails then something has tried to delete this object without
49 // calling CloseConnection. 58 // calling CloseConnection.
50 DCHECK(connection_closed_); 59 DCHECK(connection_closed_);
51 } 60 }
52 61
53 } // namespace shell 62 } // namespace shell
54 } // namespace mojo 63 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/content_handler_connection.h ('k') | mojo/shell/identity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698