native_viewport_impl.h revision f2477e01787aa58f445919b809d89e252beef54f
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
3// found in the LICENSE file.
4
5#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_
6#define MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_
7
8#include <string>
9
10#include "mojo/public/bindings/lib/remote_ptr.h"
11#include "mojo/public/system/core_cpp.h"
12#include "mojo/services/native_viewport/native_viewport.h"
13#include "mojom/native_viewport.h"
14
15namespace gpu {
16class GLInProcessContext;
17}
18
19namespace mojo {
20namespace services {
21
22class NativeViewportImpl : public NativeViewportStub,
23                           public NativeViewportDelegate {
24 public:
25  NativeViewportImpl(shell::Context* context,
26                     ScopedMessagePipeHandle pipe);
27  virtual ~NativeViewportImpl();
28
29  virtual void Open() OVERRIDE;
30  virtual void Close() OVERRIDE;
31
32 private:
33  // Overridden from services::NativeViewportDelegate:
34  virtual void OnResized(const gfx::Size& size) OVERRIDE;
35  virtual void OnAcceleratedWidgetAvailable(
36      gfx::AcceleratedWidget widget) OVERRIDE;
37  virtual bool OnEvent(ui::Event* event) OVERRIDE;
38  virtual void OnDestroyed() OVERRIDE;
39
40  void OnGLContextLost();
41
42  shell::Context* context_;
43  scoped_ptr<services::NativeViewport> native_viewport_;
44  scoped_ptr<gpu::GLInProcessContext> gl_context_;
45
46  RemotePtr<NativeViewportClient> client_;
47
48  DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl);
49};
50
51}  // namespace services
52}  // namespace mojo
53
54#endif  // MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_
55