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

Side by Side Diff: mojo/examples/compositor_app/compositor_app.cc

Issue 109103003: Mojo: abstract interface implementation from generated Stub classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + fix build Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/common/bindings_support_impl.h" 9 #include "mojo/common/bindings_support_impl.h"
10 #include "mojo/examples/compositor_app/compositor_host.h" 10 #include "mojo/examples/compositor_app/compositor_host.h"
(...skipping 12 matching lines...) Expand all
23 #endif 23 #endif
24 #define SAMPLE_APP_EXPORT __declspec(dllexport) 24 #define SAMPLE_APP_EXPORT __declspec(dllexport)
25 #else 25 #else
26 #define CDECL 26 #define CDECL
27 #define SAMPLE_APP_EXPORT __attribute__((visibility("default"))) 27 #define SAMPLE_APP_EXPORT __attribute__((visibility("default")))
28 #endif 28 #endif
29 29
30 namespace mojo { 30 namespace mojo {
31 namespace examples { 31 namespace examples {
32 32
33 class SampleApp : public ShellClientStub { 33 class SampleApp : public ShellClient {
34 public: 34 public:
35 explicit SampleApp(ScopedMessagePipeHandle shell_handle) 35 explicit SampleApp(ScopedMessagePipeHandle shell_handle)
36 : shell_(shell_handle.Pass()) { 36 : shell_(shell_handle.Pass(), this) {
37 shell_.SetPeer(this);
38 mojo::ScopedMessagePipeHandle client_handle, native_viewport_handle; 37 mojo::ScopedMessagePipeHandle client_handle, native_viewport_handle;
39 CreateMessagePipe(&client_handle, &native_viewport_handle); 38 CreateMessagePipe(&client_handle, &native_viewport_handle);
40 native_viewport_client_.reset( 39 native_viewport_client_.reset(
41 new NativeViewportClientImpl(native_viewport_handle.Pass())); 40 new NativeViewportClientImpl(native_viewport_handle.Pass()));
42 mojo::AllocationScope scope; 41 mojo::AllocationScope scope;
43 shell_->Connect("mojo:mojo_native_viewport_service", client_handle.Pass()); 42 shell_->Connect("mojo:mojo_native_viewport_service", client_handle.Pass());
44 } 43 }
45 44
46 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE { 45 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE {
47 NOTREACHED() << "SampleApp can't be connected to."; 46 NOTREACHED() << "SampleApp can't be connected to.";
48 } 47 }
49 48
50 private: 49 private:
51 class NativeViewportClientImpl : public mojo::NativeViewportClientStub { 50 class NativeViewportClientImpl : public mojo::NativeViewportClient {
52 public: 51 public:
53 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle) 52 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle)
54 : viewport_(viewport_handle.Pass()) { 53 : viewport_(viewport_handle.Pass(), this) {
55 viewport_.SetPeer(this);
56 viewport_->Open(); 54 viewport_->Open();
57 ScopedMessagePipeHandle gles2_handle; 55 ScopedMessagePipeHandle gles2_handle;
58 ScopedMessagePipeHandle gles2_client_handle; 56 ScopedMessagePipeHandle gles2_client_handle;
59 CreateMessagePipe(&gles2_handle, &gles2_client_handle); 57 CreateMessagePipe(&gles2_handle, &gles2_client_handle);
60 58
61 gles2_client_.reset(new GLES2ClientImpl( 59 gles2_client_.reset(new GLES2ClientImpl(
62 gles2_handle.Pass(), 60 gles2_handle.Pass(),
63 base::Bind(&NativeViewportClientImpl::DidCreateContext, 61 base::Bind(&NativeViewportClientImpl::DidCreateContext,
64 base::Unretained(this)))); 62 base::Unretained(this))));
65 viewport_->CreateGLES2Context(gles2_client_handle.Pass()); 63 viewport_->CreateGLES2Context(gles2_client_handle.Pass());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 MojoGLES2Initialize(); 103 MojoGLES2Initialize();
106 104
107 mojo::examples::SampleApp app( 105 mojo::examples::SampleApp app(
108 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); 106 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass());
109 loop.Run(); 107 loop.Run();
110 108
111 MojoGLES2Terminate(); 109 MojoGLES2Terminate();
112 mojo::BindingsSupport::Set(NULL); 110 mojo::BindingsSupport::Set(NULL);
113 return MOJO_RESULT_OK; 111 return MOJO_RESULT_OK;
114 } 112 }
OLDNEW
« no previous file with comments | « mojo/examples/aura_demo/root_window_host_mojo.cc ('k') | mojo/examples/compositor_app/gles2_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698