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

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

Issue 1985223003: Factor stuff from ApplicationImpl out to a new class, ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_app_test_base_no_app_impl
Patch Set: fix android Created 4 years, 7 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 2016 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/public/cpp/application/application_impl.h" 5 #include "mojo/public/cpp/application/application_impl_base.h"
6 6
7 #include <algorithm>
7 #include <utility> 8 #include <utility>
8 9
9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/connection_context.h" 10 #include "mojo/public/cpp/application/connection_context.h"
11 #include "mojo/public/cpp/application/service_provider_impl.h" 11 #include "mojo/public/cpp/application/service_provider_impl.h"
12 #include "mojo/public/cpp/bindings/interface_ptr.h"
13 #include "mojo/public/cpp/bindings/interface_request.h"
14 #include "mojo/public/cpp/environment/logging.h" 12 #include "mojo/public/cpp/environment/logging.h"
15 13
16 namespace mojo { 14 namespace mojo {
17 15
18 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 16 ApplicationImplBase::ApplicationImplBase(
19 InterfaceRequest<Application> request) 17 InterfaceRequest<Application> application_request)
20 : delegate_(delegate), application_binding_(this, request.Pass()) {} 18 : application_binding_(this, application_request.Pass()) {}
21 19
22 ApplicationImpl::~ApplicationImpl() {} 20 ApplicationImplBase::~ApplicationImplBase() {}
23 21
24 bool ApplicationImpl::HasArg(const std::string& arg) const { 22 bool ApplicationImplBase::HasArg(const std::string& arg) const {
25 return std::find(args_.begin(), args_.end(), arg) != args_.end(); 23 return std::find(args_.begin(), args_.end(), arg) != args_.end();
26 } 24 }
27 25
28 void ApplicationImpl::Initialize(InterfaceHandle<Shell> shell, 26 void ApplicationImplBase::Initialize(InterfaceHandle<Shell> shell,
29 Array<String> args, 27 Array<String> args,
30 const mojo::String& url) { 28 const mojo::String& url) {
31 shell_ = ShellPtr::Create(std::move(shell)); 29 shell_ = ShellPtr::Create(std::move(shell));
32 shell_.set_connection_error_handler([this]() { 30 shell_.set_connection_error_handler([this]() {
33 delegate_->Quit(); 31 OnQuit();
34 service_provider_impls_.clear(); 32 service_provider_impls_.clear();
35 Terminate(); 33 Terminate();
36 }); 34 });
37 url_ = url; 35 url_ = url;
38 args_ = args.To<std::vector<std::string>>(); 36 args_ = args.To<std::vector<std::string>>();
39 delegate_->Initialize(this); 37 OnInitialize();
40 } 38 }
41 39
42 void ApplicationImpl::AcceptConnection( 40 void ApplicationImplBase::AcceptConnection(
43 const String& requestor_url, 41 const String& requestor_url,
44 InterfaceRequest<ServiceProvider> services, 42 InterfaceRequest<ServiceProvider> services,
45 InterfaceHandle<ServiceProvider> exposed_services, 43 InterfaceHandle<ServiceProvider> exposed_services,
46 const String& url) { 44 const String& url) {
47 // Note: The shell no longer actually connects |exposed_services|, so a) we 45 // Note: The shell no longer actually connects |exposed_services|, so a) we
48 // never actually get valid |exposed_services| here, b) it should be OK to 46 // never actually get valid |exposed_services| here, b) it should be OK to
49 // drop it on the floor. 47 // drop it on the floor.
50 MOJO_LOG_IF(ERROR, exposed_services) 48 MOJO_LOG_IF(ERROR, exposed_services)
51 << "DEPRECATED: exposed_services is going away"; 49 << "DEPRECATED: exposed_services is going away";
52 std::unique_ptr<ServiceProviderImpl> service_provider_impl( 50 std::unique_ptr<ServiceProviderImpl> service_provider_impl(
53 new ServiceProviderImpl( 51 new ServiceProviderImpl(
54 ConnectionContext(ConnectionContext::Type::INCOMING, requestor_url, 52 ConnectionContext(ConnectionContext::Type::INCOMING, requestor_url,
55 url), 53 url),
56 services.Pass())); 54 services.Pass()));
57 if (!delegate_->ConfigureIncomingConnection(service_provider_impl.get())) 55 if (!OnAcceptConnection(service_provider_impl.get()))
58 return; 56 return;
59 service_provider_impls_.push_back(std::move(service_provider_impl)); 57 service_provider_impls_.push_back(std::move(service_provider_impl));
60 } 58 }
61 59
62 void ApplicationImpl::RequestQuit() { 60 void ApplicationImplBase::RequestQuit() {
63 delegate_->Quit(); 61 OnQuit();
64 Terminate(); 62 Terminate();
65 } 63 }
66 64
67 } // namespace mojo 65 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698