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

Side by Side Diff: mojo/application/public/cpp/lib/application_impl.cc

Issue 1195003002: Mandoline: Introduce ApplicationConnection::CloseConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/application/public/cpp/application_impl.h" 5 #include "mojo/application/public/cpp/application_impl.h"
6 6
7 #include <algorithm>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "mojo/application/public/cpp/application_delegate.h" 11 #include "mojo/application/public/cpp/application_delegate.h"
10 #include "mojo/application/public/cpp/lib/service_registry.h" 12 #include "mojo/application/public/cpp/lib/service_registry.h"
11 #include "mojo/public/cpp/bindings/interface_ptr.h" 13 #include "mojo/public/cpp/bindings/interface_ptr.h"
12 #include "mojo/public/cpp/environment/logging.h" 14 #include "mojo/public/cpp/environment/logging.h"
13 15
14 namespace mojo { 16 namespace mojo {
15 17
16 namespace { 18 namespace {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 this, application_url, application_url, remote_services.Pass(), 72 this, application_url, application_url, remote_services.Pass(),
71 local_request.Pass()); 73 local_request.Pass());
72 if (!delegate_->ConfigureOutgoingConnection(registry)) { 74 if (!delegate_->ConfigureOutgoingConnection(registry)) {
73 delete registry; 75 delete registry;
74 return nullptr; 76 return nullptr;
75 } 77 }
76 outgoing_service_registries_.push_back(registry); 78 outgoing_service_registries_.push_back(registry);
77 return registry; 79 return registry;
78 } 80 }
79 81
82 void ApplicationImpl::CloseConnection(ApplicationConnection* connection) {
83 auto it = std::find(outgoing_service_registries_.begin(),
84 outgoing_service_registries_.end(),
85 connection);
86 DCHECK(it != outgoing_service_registries_.end());
87 delete *it;
sky 2015/06/19 19:22:19 IMO I would erase first, then delete. That way you
Fady Samuel 2015/06/26 22:41:20 Done.
88 outgoing_service_registries_.erase(it);
sky 2015/06/19 19:22:19 Can't this be used for incoming connections too?
Fady Samuel 2015/06/26 22:41:20 Done.
89 }
90
80 void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) { 91 void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) {
81 shell_ = shell.Pass(); 92 shell_ = shell.Pass();
82 shell_.set_error_handler(this); 93 shell_.set_error_handler(this);
83 url_ = url; 94 url_ = url;
84 delegate_->Initialize(this); 95 delegate_->Initialize(this);
85 } 96 }
86 97
87 void ApplicationImpl::WaitForInitialize() { 98 void ApplicationImpl::WaitForInitialize() {
88 if (!shell_) 99 if (!shell_)
89 binding_.WaitForIncomingMethodCall(); 100 binding_.WaitForIncomingMethodCall();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 153
143 void ApplicationImpl::OnConnectionError() { 154 void ApplicationImpl::OnConnectionError() {
144 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr()); 155 base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr());
145 QuitNow(); 156 QuitNow();
146 if (!ptr) 157 if (!ptr)
147 return; 158 return;
148 shell_ = nullptr; 159 shell_ = nullptr;
149 } 160 }
150 161
151 } // namespace mojo 162 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698