OLD | NEW |
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 "mojo/services/native_viewport/native_viewport_service.h" | 5 #include "mojo/services/native_viewport/native_viewport_service.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 widget_ = widget; | 130 widget_ = widget; |
131 CreateCommandBufferIfNeeded(); | 131 CreateCommandBufferIfNeeded(); |
132 } | 132 } |
133 | 133 |
134 virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE { | 134 virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE { |
135 CreateCommandBufferIfNeeded(); | 135 CreateCommandBufferIfNeeded(); |
136 client()->OnBoundsChanged(Rect::From(bounds)); | 136 client()->OnBoundsChanged(Rect::From(bounds)); |
137 } | 137 } |
138 | 138 |
139 virtual void OnDestroyed() OVERRIDE { | 139 virtual void OnDestroyed() OVERRIDE { |
140 command_buffer_.reset(); | 140 client()->OnDestroyed(base::Bind(&NativeViewportImpl::AckDestroyed, |
141 client()->OnDestroyed(); | 141 base::Unretained(this))); |
142 base::MessageLoop::current()->Quit(); | |
143 } | 142 } |
144 | 143 |
145 private: | 144 private: |
| 145 void AckDestroyed() { |
| 146 command_buffer_.reset(); |
| 147 } |
| 148 |
146 shell::Context* context_; | 149 shell::Context* context_; |
147 gfx::AcceleratedWidget widget_; | 150 gfx::AcceleratedWidget widget_; |
148 scoped_ptr<services::NativeViewport> native_viewport_; | 151 scoped_ptr<services::NativeViewport> native_viewport_; |
149 InterfaceRequest<CommandBuffer> command_buffer_request_; | 152 InterfaceRequest<CommandBuffer> command_buffer_request_; |
150 scoped_ptr<CommandBufferImpl> command_buffer_; | 153 scoped_ptr<CommandBufferImpl> command_buffer_; |
151 bool waiting_for_event_ack_; | 154 bool waiting_for_event_ack_; |
152 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 155 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
153 }; | 156 }; |
154 | 157 |
155 class NVSDelegate : public ApplicationDelegate { | 158 class NVSDelegate : public ApplicationDelegate { |
(...skipping 15 matching lines...) Expand all Loading... |
171 } // namespace mojo | 174 } // namespace mojo |
172 | 175 |
173 MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* | 176 MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* |
174 CreateNativeViewportService( | 177 CreateNativeViewportService( |
175 mojo::shell::Context* context, | 178 mojo::shell::Context* context, |
176 mojo::ScopedMessagePipeHandle service_provider_handle) { | 179 mojo::ScopedMessagePipeHandle service_provider_handle) { |
177 mojo::ApplicationImpl* app = new mojo::ApplicationImpl( | 180 mojo::ApplicationImpl* app = new mojo::ApplicationImpl( |
178 new mojo::services::NVSDelegate(context), service_provider_handle.Pass()); | 181 new mojo::services::NVSDelegate(context), service_provider_handle.Pass()); |
179 return app; | 182 return app; |
180 } | 183 } |
OLD | NEW |