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

Side by Side Diff: webkit/glue/media/buffered_data_source.h

Issue 8046023: Cleaned up threadiness of BufferedDataSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: acolwell CR. Created 9 years, 2 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
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
6 #define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 6 #define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "media/base/filter_factories.h" 13 #include "media/base/filter_factories.h"
14 #include "media/base/filters.h" 14 #include "media/base/filters.h"
15 #include "webkit/glue/media/buffered_resource_loader.h" 15 #include "webkit/glue/media/buffered_resource_loader.h"
16 16
17 namespace media { 17 namespace media {
18 class MediaLog; 18 class MediaLog;
19 } 19 }
20 20
21 namespace webkit_glue { 21 namespace webkit_glue {
22 22
23 // This class may be created on any thread, and is callable from the render
24 // thread as well as media-specific threads.
23 class BufferedDataSource : public WebDataSource { 25 class BufferedDataSource : public WebDataSource {
24 public: 26 public:
25 // Creates a DataSourceFactory for building BufferedDataSource objects. 27 // Creates a DataSourceFactory for building BufferedDataSource objects.
26 static media::DataSourceFactory* CreateFactory( 28 static media::DataSourceFactory* CreateFactory(
27 MessageLoop* render_loop, 29 MessageLoop* render_loop,
28 WebKit::WebFrame* frame, 30 WebKit::WebFrame* frame,
29 media::MediaLog* media_log, 31 media::MediaLog* media_log,
30 WebDataSourceBuildObserverHack* build_observer); 32 WebDataSourceBuildObserverHack* build_observer);
31 33
32 BufferedDataSource(MessageLoop* render_loop, 34 BufferedDataSource(MessageLoop* render_loop,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void PartialReadStartCallback(int error); 124 void PartialReadStartCallback(int error);
123 125
124 // Callback method for making a read request to BufferedResourceLoader. 126 // Callback method for making a read request to BufferedResourceLoader.
125 // If data arrives or the request has failed, this method is called with 127 // If data arrives or the request has failed, this method is called with
126 // the error code or the number of bytes read. 128 // the error code or the number of bytes read.
127 void ReadCallback(int error); 129 void ReadCallback(int error);
128 130
129 // Callback method when a network event is received. 131 // Callback method when a network event is received.
130 void NetworkEventCallback(); 132 void NetworkEventCallback();
131 133
132 void UpdateHostState(); 134 void UpdateHostState_Locked();
133 135
134 // URL of the resource requested. 136 // URL of the resource requested.
135 GURL url_; 137 GURL url_;
136 138
137 // Members for total bytes of the requested object. It is written once on 139 // Members for total bytes of the requested object. It is written once on
138 // render thread but may be read from any thread. However reading of this 140 // render thread but may be read from any thread. However reading of this
139 // member is guaranteed to happen after it is first written, so we don't 141 // member is guaranteed to happen after it is first written, so we don't
140 // need to protect it. 142 // need to protect it.
141 int64 total_bytes_; 143 int64 total_bytes_;
142 int64 buffered_bytes_; 144 int64 buffered_bytes_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Memory is allocated for this member during initialization of this object 177 // Memory is allocated for this member during initialization of this object
176 // because we want buffer to be passed into BufferedResourceLoader to be 178 // because we want buffer to be passed into BufferedResourceLoader to be
177 // always non-null. And by initializing this member with a default size we can 179 // always non-null. And by initializing this member with a default size we can
178 // avoid creating zero-sized buffered if the first read has zero size. 180 // avoid creating zero-sized buffered if the first read has zero size.
179 scoped_array<uint8> intermediate_read_buffer_; 181 scoped_array<uint8> intermediate_read_buffer_;
180 int intermediate_read_buffer_size_; 182 int intermediate_read_buffer_size_;
181 183
182 // The message loop of the render thread. 184 // The message loop of the render thread.
183 MessageLoop* render_loop_; 185 MessageLoop* render_loop_;
184 186
185 // Protects |stopped_|. 187 // Protects |stop_signal_received_|, |stopped_on_render_loop_| and
188 // |initialize_cb_|.
186 base::Lock lock_; 189 base::Lock lock_;
187 190
188 // Stop signal to suppressing activities. This variable is set on the pipeline 191 // Stop signal to suppressing activities. This variable is set on the pipeline
189 // thread and read from the render thread. 192 // thread and read from the render thread.
190 bool stop_signal_received_; 193 bool stop_signal_received_;
191 194
192 // This variable is set by CleanupTask() that indicates this object is stopped 195 // This variable is set by CleanupTask() that indicates this object is stopped
193 // on the render thread and work should no longer progress. 196 // on the render thread and work should no longer progress.
194 bool stopped_on_render_loop_; 197 bool stopped_on_render_loop_;
195 198
(...skipping 17 matching lines...) Expand all
213 int cache_miss_retries_left_; 216 int cache_miss_retries_left_;
214 217
215 scoped_refptr<media::MediaLog> media_log_; 218 scoped_refptr<media::MediaLog> media_log_;
216 219
217 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 220 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
218 }; 221 };
219 222
220 } // namespace webkit_glue 223 } // namespace webkit_glue
221 224
222 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 225 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698