summaryrefslogtreecommitdiffstats
path: root/content/renderer/gpu/gpu_surface_proxy.h
blob: f4f8879090e5dbb5759c8d715694fe451ecb643a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_GPU_GPU_SURFACE_PROXY_H_
#define CONTENT_RENDERER_GPU_GPU_SURFACE_PROXY_H_
#pragma once

#if defined(ENABLE_GPU)

#include "base/memory/weak_ptr.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message.h"

namespace gfx {
class Size;
}

// Client side proxy that forwards messages to a GpuSurfaceStub.
class GpuSurfaceProxy : public IPC::Channel::Listener,
                        public base::SupportsWeakPtr<GpuSurfaceProxy> {
 public:
  GpuSurfaceProxy(IPC::Channel::Sender* channel, int route_id);
  virtual ~GpuSurfaceProxy();

  // IPC::Channel::Listener implementation:
  virtual bool OnMessageReceived(const IPC::Message& message);
  virtual void OnChannelError();

  int route_id() const { return route_id_; }

 private:

  // Send an IPC message over the GPU channel. This is private to fully
  // encapsulate the channel; all callers of this function must explicitly
  // verify that the channel is still available.
  bool Send(IPC::Message* msg);

  IPC::Channel::Sender* channel_;
  int route_id_;

  DISALLOW_COPY_AND_ASSIGN(GpuSurfaceProxy);
};

#endif  // ENABLE_GPU

#endif  // CONTENT_RENDERER_GPU_GPU_SURFACE_PROXY_H_