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

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

Issue 858103002: Remove [Client=] annotation from ServiceProvider (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase for trybots (no code changes from ps2) Created 5 years, 11 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/browser/browser.cc ('k') | examples/ganesh_app/ganesh_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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "examples/bitmap_uploader/bitmap_uploader.h" 10 #include "examples/bitmap_uploader/bitmap_uploader.h"
(...skipping 15 matching lines...) Expand all
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 #include "url/url_util.h" 27 #include "url/url_util.h"
28 28
29 namespace mojo { 29 namespace mojo {
30 namespace examples { 30 namespace examples {
31 31
32 const SkColor kColors[] = {SK_ColorYELLOW, SK_ColorRED, SK_ColorGREEN, 32 const SkColor kColors[] = {SK_ColorYELLOW, SK_ColorRED, SK_ColorGREEN,
33 SK_ColorMAGENTA}; 33 SK_ColorMAGENTA};
34 34
35 struct Window { 35 struct Window {
36 Window(View* root, 36 Window(View* root, ServiceProviderPtr embedder_service_provider, Shell* shell)
37 scoped_ptr<ServiceProvider> embedder_service_provider,
38 Shell* shell)
39 : root(root), 37 : root(root),
40 embedder_service_provider(embedder_service_provider.Pass()), 38 embedder_service_provider(embedder_service_provider.Pass()),
41 bitmap_uploader(root) { 39 bitmap_uploader(root) {
42 bitmap_uploader.Init(shell); 40 bitmap_uploader.Init(shell);
43 } 41 }
44 42
45 View* root; 43 View* root;
46 scoped_ptr<ServiceProvider> embedder_service_provider; 44 ServiceProviderPtr embedder_service_provider;
47 BitmapUploader bitmap_uploader; 45 BitmapUploader bitmap_uploader;
48 }; 46 };
49 47
50 class EmbeddedApp 48 class EmbeddedApp
51 : public ApplicationDelegate, 49 : public ApplicationDelegate,
52 public ViewManagerDelegate, 50 public ViewManagerDelegate,
53 public ViewObserver { 51 public ViewObserver {
54 public: 52 public:
55 EmbeddedApp() : shell_(nullptr) { url::AddStandardScheme("mojo"); } 53 EmbeddedApp() : shell_(nullptr) { url::AddStandardScheme("mojo"); }
56 virtual ~EmbeddedApp() {} 54 virtual ~EmbeddedApp() {}
57 55
58 private: 56 private:
59 57
60 // Overridden from ApplicationDelegate: 58 // Overridden from ApplicationDelegate:
61 virtual void Initialize(ApplicationImpl* app) override { 59 virtual void Initialize(ApplicationImpl* app) override {
62 shell_ = app->shell(); 60 shell_ = app->shell();
63 view_manager_client_factory_.reset( 61 view_manager_client_factory_.reset(
64 new ViewManagerClientFactory(app->shell(), this)); 62 new ViewManagerClientFactory(app->shell(), this));
65 } 63 }
66 64
67 virtual bool ConfigureIncomingConnection( 65 virtual bool ConfigureIncomingConnection(
68 ApplicationConnection* connection) override { 66 ApplicationConnection* connection) override {
69 connection->AddService(view_manager_client_factory_.get()); 67 connection->AddService(view_manager_client_factory_.get());
70 return true; 68 return true;
71 } 69 }
72 70
73 // Overridden from ViewManagerDelegate: 71 // Overridden from ViewManagerDelegate:
74 virtual void OnEmbed(View* root, 72 virtual void OnEmbed(View* root,
75 ServiceProviderImpl* exported_services, 73 InterfaceRequest<ServiceProvider> services,
76 scoped_ptr<ServiceProvider> imported_services) override { 74 ServiceProviderPtr exposed_services) override {
77 root->AddObserver(this); 75 root->AddObserver(this);
78 Window* window = new Window(root, imported_services.Pass(), shell_); 76 Window* window = new Window(root, exposed_services.Pass(), shell_);
79 windows_[root->id()] = window; 77 windows_[root->id()] = window;
80 window->bitmap_uploader.SetColor( 78 window->bitmap_uploader.SetColor(
81 kColors[next_color_++ % arraysize(kColors)]); 79 kColors[next_color_++ % arraysize(kColors)]);
82 } 80 }
83 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override { 81 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {
84 base::MessageLoop::current()->Quit(); 82 base::MessageLoop::current()->Quit();
85 } 83 }
86 84
87 // Overridden from ViewObserver: 85 // Overridden from ViewObserver:
88 virtual void OnViewDestroyed(View* view) override { 86 virtual void OnViewDestroyed(View* view) override {
(...skipping 24 matching lines...) Expand all
113 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp); 111 DISALLOW_COPY_AND_ASSIGN(EmbeddedApp);
114 }; 112 };
115 113
116 } // namespace examples 114 } // namespace examples
117 } // namespace mojo 115 } // namespace mojo
118 116
119 MojoResult MojoMain(MojoHandle shell_handle) { 117 MojoResult MojoMain(MojoHandle shell_handle) {
120 mojo::ApplicationRunnerChromium runner(new mojo::examples::EmbeddedApp); 118 mojo::ApplicationRunnerChromium runner(new mojo::examples::EmbeddedApp);
121 return runner.Run(shell_handle); 119 return runner.Run(shell_handle);
122 } 120 }
OLDNEW
« no previous file with comments | « examples/browser/browser.cc ('k') | examples/ganesh_app/ganesh_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698