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

Side by Side Diff: media/filters/file_data_source.cc

Issue 10067035: RefCounted types should not have public destructors, media/ and gpu/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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 | « media/filters/file_data_source.h ('k') | media/filters/gpu_video_decoder.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <limits> 5 #include <limits>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
11 #include "media/base/filters.h" 11 #include "media/base/filters.h"
12 #include "media/base/pipeline.h" 12 #include "media/base/pipeline.h"
13 #include "media/filters/file_data_source.h" 13 #include "media/filters/file_data_source.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 FileDataSource::FileDataSource() 17 FileDataSource::FileDataSource()
18 : file_(NULL), 18 : file_(NULL),
19 file_size_(0), 19 file_size_(0),
20 disable_file_size_(false) { 20 disable_file_size_(false) {
21 } 21 }
22 22
23 FileDataSource::FileDataSource(bool disable_file_size) 23 FileDataSource::FileDataSource(bool disable_file_size)
24 : file_(NULL), 24 : file_(NULL),
25 file_size_(0), 25 file_size_(0),
26 disable_file_size_(disable_file_size) { 26 disable_file_size_(disable_file_size) {
27 } 27 }
28 28
29 FileDataSource::~FileDataSource() {
30 DCHECK(!file_);
31 }
32
33 PipelineStatus FileDataSource::Initialize(const std::string& url) { 29 PipelineStatus FileDataSource::Initialize(const std::string& url) {
34 DCHECK(!file_); 30 DCHECK(!file_);
35 #if defined(OS_WIN) 31 #if defined(OS_WIN)
36 FilePath file_path(UTF8ToWide(url)); 32 FilePath file_path(UTF8ToWide(url));
37 #else 33 #else
38 FilePath file_path(url); 34 FilePath file_path(url);
39 #endif 35 #endif
40 if (file_util::GetFileSize(file_path, &file_size_)) { 36 if (file_util::GetFileSize(file_path, &file_size_)) {
41 file_ = file_util::OpenFile(file_path, "rb"); 37 file_ = file_util::OpenFile(file_path, "rb");
42 } 38 }
43 if (!file_) { 39 if (!file_) {
44 file_size_ = 0; 40 file_size_ = 0;
45 return PIPELINE_ERROR_URL_NOT_FOUND; 41 return PIPELINE_ERROR_URL_NOT_FOUND;
46 } 42 }
47 UpdateHostBytes(); 43 UpdateHostBytes();
48 44
49 return PIPELINE_OK; 45 return PIPELINE_OK;
50 } 46 }
51 47
52 void FileDataSource::set_host(DataSourceHost* host) { 48 void FileDataSource::set_host(DataSourceHost* host) {
53 DataSource::set_host(host); 49 DataSource::set_host(host);
54 UpdateHostBytes(); 50 UpdateHostBytes();
55 } 51 }
56 52
57 void FileDataSource::UpdateHostBytes() {
58 if (host() && file_) {
59 host()->SetTotalBytes(file_size_);
60 host()->SetBufferedBytes(file_size_);
61 }
62 }
63
64 void FileDataSource::Stop(const base::Closure& callback) { 53 void FileDataSource::Stop(const base::Closure& callback) {
65 base::AutoLock l(lock_); 54 base::AutoLock l(lock_);
66 if (file_) { 55 if (file_) {
67 file_util::CloseFile(file_); 56 file_util::CloseFile(file_);
68 file_ = NULL; 57 file_ = NULL;
69 file_size_ = 0; 58 file_size_ = 0;
70 } 59 }
71 if (!callback.is_null()) 60 if (!callback.is_null())
72 callback.Run(); 61 callback.Run();
73 } 62 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 *size_out = file_size_; 96 *size_out = file_size_;
108 return (NULL != file_ && !disable_file_size_); 97 return (NULL != file_ && !disable_file_size_);
109 } 98 }
110 99
111 bool FileDataSource::IsStreaming() { 100 bool FileDataSource::IsStreaming() {
112 return false; 101 return false;
113 } 102 }
114 103
115 void FileDataSource::SetBitrate(int bitrate) {} 104 void FileDataSource::SetBitrate(int bitrate) {}
116 105
106 FileDataSource::~FileDataSource() {
107 DCHECK(!file_);
108 }
109
110 void FileDataSource::UpdateHostBytes() {
111 if (host() && file_) {
112 host()->SetTotalBytes(file_size_);
113 host()->SetBufferedBytes(file_size_);
114 }
115 }
116
117 } // namespace media 117 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/file_data_source.h ('k') | media/filters/gpu_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698