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

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

Issue 1354003002: Make CapabilityFilter be part of Identity (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
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 "base/memory/scoped_ptr.h"
8 #include "mojo/shell/application_manager.h" 8 #include "mojo/shell/application_manager.h"
9 #include "mojo/shell/connect_to_application_params.h" 9 #include "mojo/shell/connect_to_application_params.h"
10 #include "mojo/shell/identity.h" 10 #include "mojo/shell/identity.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace shell { 13 namespace shell {
14 14
15 ContentHandlerConnection::ContentHandlerConnection( 15 ContentHandlerConnection::ContentHandlerConnection(
16 ApplicationManager* manager, 16 ApplicationManager* manager,
17 const Identity& originator_identity, 17 const Identity& source,
18 const CapabilityFilter& originator_filter, 18 const Identity& content_handler,
19 const GURL& content_handler_url,
20 const std::string& qualifier,
21 const CapabilityFilter& filter,
22 uint32_t id) 19 uint32_t id)
23 : manager_(manager), 20 : manager_(manager),
24 content_handler_url_(content_handler_url), 21 identity_(content_handler),
25 content_handler_qualifier_(qualifier),
26 connection_closed_(false), 22 connection_closed_(false),
27 id_(id) { 23 id_(id) {
28 ServiceProviderPtr services; 24 ServiceProviderPtr services;
29 25
30 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams); 26 scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
31 params->set_originator_identity(originator_identity); 27 params->set_source(source);
32 params->set_originator_filter(originator_filter); 28 params->SetTarget(identity_);
33 params->SetURLInfo(content_handler_url);
34 params->set_qualifier(qualifier);
35 params->set_services(GetProxy(&services)); 29 params->set_services(GetProxy(&services));
36 params->set_filter(filter);
37
38 manager->ConnectToApplication(params.Pass()); 30 manager->ConnectToApplication(params.Pass());
39 31
40 MessagePipe pipe; 32 MessagePipe pipe;
41 content_handler_.Bind( 33 content_handler_.Bind(
42 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); 34 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
43 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); 35 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
44 content_handler_.set_connection_error_handler( 36 content_handler_.set_connection_error_handler(
45 [this]() { CloseConnection(); }); 37 [this]() { CloseConnection(); });
46 } 38 }
47 39
48 void ContentHandlerConnection::CloseConnection() { 40 void ContentHandlerConnection::CloseConnection() {
49 if (connection_closed_) 41 if (connection_closed_)
50 return; 42 return;
51 connection_closed_ = true; 43 connection_closed_ = true;
52 manager_->OnContentHandlerConnectionClosed(this); 44 manager_->OnContentHandlerConnectionClosed(this);
53 delete this; 45 delete this;
54 } 46 }
55 47
56 ContentHandlerConnection::~ContentHandlerConnection() { 48 ContentHandlerConnection::~ContentHandlerConnection() {
57 // If this DCHECK fails then something has tried to delete this object without 49 // If this DCHECK fails then something has tried to delete this object without
58 // calling CloseConnection. 50 // calling CloseConnection.
59 DCHECK(connection_closed_); 51 DCHECK(connection_closed_);
60 } 52 }
61 53
62 } // namespace shell 54 } // namespace shell
63 } // namespace mojo 55 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698