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

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

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

Powered by Google App Engine
This is Rietveld 408576698