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

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

Issue 1525033004: Always set the error handler closure of Binding<> after binding to a message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
« no previous file with comments | « mojo/runner/host/child_process.cc ('k') | net/proxy/proxy_resolver_factory_mojo.cc » ('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/application_instance.h" 5 #include "mojo/shell/application_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "mojo/application/public/interfaces/content_handler.mojom.h" 9 #include "mojo/application/public/interfaces/content_handler.mojom.h"
10 #include "mojo/common/common_type_converters.h" 10 #include "mojo/common/common_type_converters.h"
(...skipping 13 matching lines...) Expand all
24 identity_(identity), 24 identity_(identity),
25 allow_any_application_(identity.filter().size() == 1 && 25 allow_any_application_(identity.filter().size() == 1 &&
26 identity.filter().count("*") == 1), 26 identity.filter().count("*") == 1),
27 requesting_content_handler_id_(requesting_content_handler_id), 27 requesting_content_handler_id_(requesting_content_handler_id),
28 on_application_end_(on_application_end), 28 on_application_end_(on_application_end),
29 application_(application.Pass()), 29 application_(application.Pass()),
30 binding_(this), 30 binding_(this),
31 queue_requests_(false), 31 queue_requests_(false),
32 native_runner_(nullptr), 32 native_runner_(nullptr),
33 pid_(base::kNullProcessId) { 33 pid_(base::kNullProcessId) {
34 binding_.set_connection_error_handler([this]() { OnConnectionError(); });
35 } 34 }
36 35
37 ApplicationInstance::~ApplicationInstance() { 36 ApplicationInstance::~ApplicationInstance() {
38 for (auto request : queued_client_requests_) 37 for (auto request : queued_client_requests_)
39 request->connect_callback().Run(kInvalidContentHandlerID); 38 request->connect_callback().Run(kInvalidContentHandlerID);
40 STLDeleteElements(&queued_client_requests_); 39 STLDeleteElements(&queued_client_requests_);
41 } 40 }
42 41
43 void ApplicationInstance::InitializeApplication() { 42 void ApplicationInstance::InitializeApplication() {
44 ShellPtr shell; 43 ShellPtr shell;
45 binding_.Bind(GetProxy(&shell)); 44 binding_.Bind(GetProxy(&shell));
45 binding_.set_connection_error_handler([this]() { OnConnectionError(); });
46 application_->Initialize(shell.Pass(), identity_.url().spec()); 46 application_->Initialize(shell.Pass(), identity_.url().spec());
47 } 47 }
48 48
49 void ApplicationInstance::ConnectToClient( 49 void ApplicationInstance::ConnectToClient(
50 scoped_ptr<ConnectToApplicationParams> params) { 50 scoped_ptr<ConnectToApplicationParams> params) {
51 if (queue_requests_) { 51 if (queue_requests_) {
52 queued_client_requests_.push_back(params.release()); 52 queued_client_requests_.push_back(params.release());
53 return; 53 return;
54 } 54 }
55 55
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 queue_requests_ = false; 168 queue_requests_ = false;
169 for (auto request : queued_client_requests_) 169 for (auto request : queued_client_requests_)
170 CallAcceptConnection(make_scoped_ptr(request)); 170 CallAcceptConnection(make_scoped_ptr(request));
171 171
172 queued_client_requests_.clear(); 172 queued_client_requests_.clear();
173 } 173 }
174 174
175 } // namespace shell 175 } // namespace shell
176 } // namespace mojo 176 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/host/child_process.cc ('k') | net/proxy/proxy_resolver_factory_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698