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

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

Issue 1538823002: Convert Pass()→std::move() in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/package_manager/content_handler_connection.h" 5 #include "mojo/package_manager/content_handler_connection.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "mojo/shell/application_manager.h" 11 #include "mojo/shell/application_manager.h"
10 #include "mojo/shell/connect_to_application_params.h" 12 #include "mojo/shell/connect_to_application_params.h"
11 #include "mojo/shell/identity.h" 13 #include "mojo/shell/identity.h"
12 14
13 namespace mojo { 15 namespace mojo {
14 namespace package_manager { 16 namespace package_manager {
15 17
16 ContentHandlerConnection::ContentHandlerConnection( 18 ContentHandlerConnection::ContentHandlerConnection(
17 shell::ApplicationManager* manager, 19 shell::ApplicationManager* manager,
18 const shell::Identity& source, 20 const shell::Identity& source,
19 const shell::Identity& content_handler, 21 const shell::Identity& content_handler,
20 uint32_t id, 22 uint32_t id,
21 const ClosedCallback& connection_closed_callback) 23 const ClosedCallback& connection_closed_callback)
22 : connection_closed_callback_(connection_closed_callback), 24 : connection_closed_callback_(connection_closed_callback),
23 identity_(content_handler), 25 identity_(content_handler),
24 connection_closed_(false), 26 connection_closed_(false),
25 id_(id), 27 id_(id),
26 ref_count_(0) { 28 ref_count_(0) {
27 ServiceProviderPtr services; 29 ServiceProviderPtr services;
28 30
29 scoped_ptr<shell::ConnectToApplicationParams> params( 31 scoped_ptr<shell::ConnectToApplicationParams> params(
30 new shell::ConnectToApplicationParams); 32 new shell::ConnectToApplicationParams);
31 params->set_source(source); 33 params->set_source(source);
32 params->SetTarget(identity_); 34 params->SetTarget(identity_);
33 params->set_services(GetProxy(&services)); 35 params->set_services(GetProxy(&services));
34 manager->ConnectToApplication(params.Pass()); 36 manager->ConnectToApplication(std::move(params));
35 37
36 MessagePipe pipe; 38 MessagePipe pipe;
37 content_handler_.Bind( 39 content_handler_.Bind(
38 InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u)); 40 InterfacePtrInfo<ContentHandler>(std::move(pipe.handle0), 0u));
39 services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass()); 41 services->ConnectToService(ContentHandler::Name_, std::move(pipe.handle1));
40 content_handler_.set_connection_error_handler( 42 content_handler_.set_connection_error_handler(
41 [this]() { CloseConnection(); }); 43 [this]() { CloseConnection(); });
42 } 44 }
43 45
44 void ContentHandlerConnection::StartApplication( 46 void ContentHandlerConnection::StartApplication(
45 InterfaceRequest<Application> request, 47 InterfaceRequest<Application> request,
46 URLResponsePtr response) { 48 URLResponsePtr response) {
47 content_handler_->StartApplication( 49 content_handler_->StartApplication(
48 request.Pass(), response.Pass(), 50 std::move(request), std::move(response),
49 base::Bind(&ContentHandlerConnection::ApplicationDestructed, 51 base::Bind(&ContentHandlerConnection::ApplicationDestructed,
50 base::Unretained(this))); 52 base::Unretained(this)));
51 ref_count_++; 53 ref_count_++;
52 } 54 }
53 55
54 void ContentHandlerConnection::CloseConnection() { 56 void ContentHandlerConnection::CloseConnection() {
55 if (connection_closed_) 57 if (connection_closed_)
56 return; 58 return;
57 connection_closed_ = true; 59 connection_closed_ = true;
58 connection_closed_callback_.Run(this); 60 connection_closed_callback_.Run(this);
59 delete this; 61 delete this;
60 } 62 }
61 63
62 ContentHandlerConnection::~ContentHandlerConnection() { 64 ContentHandlerConnection::~ContentHandlerConnection() {
63 // If this DCHECK fails then something has tried to delete this object without 65 // If this DCHECK fails then something has tried to delete this object without
64 // calling CloseConnection. 66 // calling CloseConnection.
65 DCHECK(connection_closed_); 67 DCHECK(connection_closed_);
66 } 68 }
67 69
68 void ContentHandlerConnection::ApplicationDestructed() { 70 void ContentHandlerConnection::ApplicationDestructed() {
69 if (!--ref_count_) 71 if (!--ref_count_)
70 CloseConnection(); 72 CloseConnection();
71 } 73 }
72 74
73 } // namespace package_manager 75 } // namespace package_manager
74 } // namespace mojo 76 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/package_manager/capability_filter_content_handler_unittest.cc ('k') | mojo/package_manager/content_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698