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

Side by Side Diff: remoting/client/plugin/pepper_view_proxy.cc

Issue 6359010: Add PepperViewProxy to protect PepperView and ChromotingInstance on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: done Created 9 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
(Empty)
1 // Copyright (c) 2011 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 #include "remoting/client/plugin/pepper_view_proxy.h"
6
7 #include "base/message_loop.h"
8 #include "remoting/base/tracer.h"
9 #include "remoting/client/client_context.h"
10 #include "remoting/client/plugin/chromoting_instance.h"
11 #include "remoting/client/plugin/pepper_util.h"
12
13 namespace remoting {
14
15 PepperViewProxy::PepperViewProxy(ChromotingInstance* instance, PepperView* view)
16 : instance_(instance),
17 view_(view) {
18 }
19
20 PepperViewProxy::~PepperViewProxy() {
21 }
22
23 bool PepperViewProxy::Initialize() {
24 // This method needs a return value so we can't post a task and process on
25 // another thread so just return true since PepperView doesn't do anything
26 // either.
27 return true;
28 }
29
30 void PepperViewProxy::TearDown() {
31 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
32 RunTaskOnPluginThread(NewTracedMethod(this, &PepperViewProxy::TearDown));
33 return;
34 }
35
36 if (view_)
37 view_->TearDown();
38 }
39
40 void PepperViewProxy::Paint() {
41 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
42 RunTaskOnPluginThread(NewTracedMethod(this, &PepperViewProxy::Paint));
43 return;
44 }
45
46 if (view_)
47 view_->Paint();
48 }
49
50 void PepperViewProxy::SetSolidFill(uint32 color) {
51 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
52 RunTaskOnPluginThread(
53 NewTracedMethod(this, &PepperViewProxy::SetSolidFill, color));
54 return;
55 }
56
57 if (view_)
58 view_->SetSolidFill(color);
59 }
60
61 void PepperViewProxy::UnsetSolidFill() {
62 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
63 RunTaskOnPluginThread(
64 NewTracedMethod(this, &PepperViewProxy::UnsetSolidFill));
65 return;
66 }
67
68 if (view_)
69 view_->UnsetSolidFill();
70 }
71
72 void PepperViewProxy::SetConnectionState(ConnectionState state) {
73 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
74 RunTaskOnPluginThread(
75 NewRunnableMethod(this, &PepperViewProxy::SetConnectionState, state));
76 return;
77 }
78
79 if (view_)
80 view_->SetConnectionState(state);
81 }
82
83 void PepperViewProxy::SetViewport(int x, int y, int width, int height) {
84 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
85 RunTaskOnPluginThread(NewTracedMethod(this, &PepperViewProxy::SetViewport,
86 x, y, width, height));
87 return;
88 }
89
90 if (view_)
91 view_->SetViewport(x, y, width, height);
92 }
93
94 void PepperViewProxy::AllocateFrame(
95 media::VideoFrame::Format format,
96 size_t width,
97 size_t height,
98 base::TimeDelta timestamp,
99 base::TimeDelta duration,
100 scoped_refptr<media::VideoFrame>* frame_out,
101 Task* done) {
102 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
103 RunTaskOnPluginThread(
104 NewTracedMethod(this, &PepperViewProxy::AllocateFrame, format, width,
105 height, timestamp, duration, frame_out, done));
106 return;
107 }
108
109 if (view_) {
110 view_->AllocateFrame(format, width, height, timestamp, duration, frame_out,
111 done);
112 }
113 }
114
115 void PepperViewProxy::ReleaseFrame(media::VideoFrame* frame) {
116 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
117 RunTaskOnPluginThread(
118 NewTracedMethod(this, &PepperViewProxy::ReleaseFrame,
119 make_scoped_refptr(frame)));
120 return;
121 }
122
123 if (view_)
124 view_->ReleaseFrame(frame);
125 }
126
127 void PepperViewProxy::OnPartialFrameOutput(media::VideoFrame* frame,
128 UpdatedRects* rects,
129 Task* done) {
130 if (instance_ && !instance_->CurrentlyOnPluginThread()) {
131 RunTaskOnPluginThread(
132 NewTracedMethod(this, &PepperViewProxy::OnPartialFrameOutput,
133 make_scoped_refptr(frame), rects, done));
134 return;
135 }
136
137 if (view_)
138 view_->OnPartialFrameOutput(frame, rects, done);
139 }
140
141 void PepperViewProxy::Detach() {
142 DCHECK(instance_->CurrentlyOnPluginThread());
143 instance_ = NULL;
144 view_ = NULL;
145 }
146
147 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698