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

Side by Side Diff: examples/forwarding_content_handler/forwarding_content_handler.cc

Issue 2015363003: Yet more ApplicationDelegate -> ApplicationImplBase conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work797-x-work796_no_run_main_app
Patch Set: rebased again Created 4 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
« no previous file with comments | « examples/echo/echo_benchmark.cc ('k') | examples/trace_me/trace_me_app.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 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 <utility> 5 #include <utility>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "mojo/application/application_runner_chromium.h"
10 #include "mojo/application/content_handler_factory.h" 9 #include "mojo/application/content_handler_factory.h"
11 #include "mojo/data_pipe_utils/data_pipe_utils.h" 10 #include "mojo/data_pipe_utils/data_pipe_utils.h"
11 #include "mojo/environment/scoped_chromium_init.h"
12 #include "mojo/public/c/system/main.h" 12 #include "mojo/public/c/system/main.h"
13 #include "mojo/public/cpp/application/application_delegate.h" 13 #include "mojo/public/cpp/application/application_impl_base.h"
14 #include "mojo/public/cpp/application/run_application.h"
14 #include "mojo/public/cpp/application/service_provider_impl.h" 15 #include "mojo/public/cpp/application/service_provider_impl.h"
15 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/utility/run_loop.h" 17 #include "mojo/public/cpp/utility/run_loop.h"
17 #include "mojo/public/interfaces/application/application.mojom.h" 18 #include "mojo/public/interfaces/application/application.mojom.h"
18 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" 19 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
19 20
20 namespace mojo { 21 namespace mojo {
21 namespace examples { 22 namespace examples {
22 23
23 class ForwardingApplicationImpl : public Application { 24 class ForwardingApplicationImpl : public Application {
(...skipping 20 matching lines...) Expand all
44 } 45 }
45 void RequestQuit() override { 46 void RequestQuit() override {
46 RunLoop::current()->Quit(); 47 RunLoop::current()->Quit();
47 } 48 }
48 49
49 Binding<Application> binding_; 50 Binding<Application> binding_;
50 std::string target_url_; 51 std::string target_url_;
51 ShellPtr shell_; 52 ShellPtr shell_;
52 }; 53 };
53 54
54 class ForwardingContentHandler : public ApplicationDelegate, 55 class ForwardingContentHandler : public ApplicationImplBase,
55 public ContentHandlerFactory::ManagedDelegate { 56 public ContentHandlerFactory::ManagedDelegate {
56 public: 57 public:
57 ForwardingContentHandler() {} 58 ForwardingContentHandler() {}
58 59
59 private: 60 private:
60 // Overridden from ApplicationDelegate: 61 // Overridden from ApplicationImplBase:
61 bool ConfigureIncomingConnection( 62 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override {
62 ServiceProviderImpl* service_provider_impl) override {
63 service_provider_impl->AddService<ContentHandler>( 63 service_provider_impl->AddService<ContentHandler>(
64 ContentHandlerFactory::GetInterfaceRequestHandler(this)); 64 ContentHandlerFactory::GetInterfaceRequestHandler(this));
65 return true; 65 return true;
66 } 66 }
67 67
68 // Overridden from ContentHandlerFactory::ManagedDelegate: 68 // Overridden from ContentHandlerFactory::ManagedDelegate:
69 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> 69 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
70 CreateApplication(InterfaceRequest<Application> application_request, 70 CreateApplication(InterfaceRequest<Application> application_request,
71 URLResponsePtr response) override { 71 URLResponsePtr response) override {
72 CHECK(!response.is_null()); 72 CHECK(!response.is_null());
73 const std::string requestor_url(response->url); 73 const std::string requestor_url(response->url);
74 std::string target_url; 74 std::string target_url;
75 if (!common::BlockingCopyToString(response->body.Pass(), &target_url)) { 75 if (!common::BlockingCopyToString(response->body.Pass(), &target_url)) {
76 LOG(WARNING) << "unable to read target URL from " << requestor_url; 76 LOG(WARNING) << "unable to read target URL from " << requestor_url;
77 return nullptr; 77 return nullptr;
78 } 78 }
79 return make_handled_factory_holder( 79 return make_handled_factory_holder(
80 new ForwardingApplicationImpl(application_request.Pass(), target_url)); 80 new ForwardingApplicationImpl(application_request.Pass(), target_url));
81 } 81 }
82 82
83 DISALLOW_COPY_AND_ASSIGN(ForwardingContentHandler); 83 DISALLOW_COPY_AND_ASSIGN(ForwardingContentHandler);
84 }; 84 };
85 85
86 } // namespace examples 86 } // namespace examples
87 } // namespace mojo 87 } // namespace mojo
88 88
89 MojoResult MojoMain(MojoHandle application_request) { 89 MojoResult MojoMain(MojoHandle application_request) {
90 mojo::ApplicationRunnerChromium runner( 90 mojo::ScopedChromiumInit init;
91 new mojo::examples::ForwardingContentHandler()); 91 mojo::examples::ForwardingContentHandler forwarding_content_handler;
92 return runner.Run(application_request); 92 return mojo::RunApplication(application_request, &forwarding_content_handler);
93 } 93 }
OLDNEW
« no previous file with comments | « examples/echo/echo_benchmark.cc ('k') | examples/trace_me/trace_me_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698