OLD | NEW |
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 #include "media/base/async_filter_factory_base.h" | 5 #include "media/base/async_filter_factory_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 outstanding_requests_.insert(request); | 43 outstanding_requests_.insert(request); |
44 } | 44 } |
45 | 45 |
46 request->Start(NewCallback(this, | 46 request->Start(NewCallback(this, |
47 &AsyncDataSourceFactoryBase::BuildRequestDone)); | 47 &AsyncDataSourceFactoryBase::BuildRequestDone)); |
48 } | 48 } |
49 | 49 |
50 void AsyncDataSourceFactoryBase::RunAndDestroyCallback( | 50 void AsyncDataSourceFactoryBase::RunAndDestroyCallback( |
51 PipelineError error, | 51 PipelineStatus error, |
52 BuildCallback* callback) const { | 52 BuildCallback* callback) const { |
53 DCHECK_NE(error, PIPELINE_OK); | 53 DCHECK_NE(error, PIPELINE_OK); |
54 DCHECK(callback); | 54 DCHECK(callback); |
55 | 55 |
56 callback->Run(error, static_cast<DataSource*>(NULL)); | 56 callback->Run(error, static_cast<DataSource*>(NULL)); |
57 delete callback; | 57 delete callback; |
58 } | 58 } |
59 | 59 |
60 void AsyncDataSourceFactoryBase::BuildRequestDone(BuildRequest* request) { | 60 void AsyncDataSourceFactoryBase::BuildRequestDone(BuildRequest* request) { |
61 base::AutoLock auto_lock(lock_); | 61 base::AutoLock auto_lock(lock_); |
(...skipping 15 matching lines...) Expand all Loading... |
77 DCHECK(!done_callback_.get()); | 77 DCHECK(!done_callback_.get()); |
78 | 78 |
79 done_callback_.reset(done_callback); | 79 done_callback_.reset(done_callback); |
80 DoStart(); | 80 DoStart(); |
81 // Don't do anything after this line since the object could | 81 // Don't do anything after this line since the object could |
82 // have been deleted at this point if the request was completed | 82 // have been deleted at this point if the request was completed |
83 // inside the call. | 83 // inside the call. |
84 } | 84 } |
85 | 85 |
86 void AsyncDataSourceFactoryBase::BuildRequest::RequestComplete( | 86 void AsyncDataSourceFactoryBase::BuildRequest::RequestComplete( |
87 PipelineError error, | 87 PipelineStatus status, |
88 DataSource* data_source) { | 88 DataSource* data_source) { |
89 DCHECK(callback_.get()); | 89 DCHECK(callback_.get()); |
90 DCHECK(done_callback_.get()); | 90 DCHECK(done_callback_.get()); |
91 | 91 |
92 // Transfer ownership to local variables just in case the | 92 // Transfer ownership to local variables just in case the |
93 // request object gets deleted by one of the callbacks. | 93 // request object gets deleted by one of the callbacks. |
94 scoped_ptr<RequestDoneCallback> done_callback(done_callback_.release()); | 94 scoped_ptr<RequestDoneCallback> done_callback(done_callback_.release()); |
95 scoped_ptr<BuildCallback> callback(callback_.release()); | 95 scoped_ptr<BuildCallback> callback(callback_.release()); |
96 | 96 |
97 // Notify factory that this request has completed. We do this before | 97 // Notify factory that this request has completed. We do this before |
98 // calling |callback| so the factory doesn't consider this request | 98 // calling |callback| so the factory doesn't consider this request |
99 // pending if |callback| happens to destroy the factory. | 99 // pending if |callback| happens to destroy the factory. |
100 // | 100 // |
101 // NOTE: This BuildRequest object is destroyed inside this callback so | 101 // NOTE: This BuildRequest object is destroyed inside this callback so |
102 // no modifications should be made to this object after this call. | 102 // no modifications should be made to this object after this call. |
103 done_callback->Run(this); | 103 done_callback->Run(this); |
104 | 104 |
105 callback->Run(error, data_source); | 105 callback->Run(status, data_source); |
106 } | 106 } |
107 | 107 |
108 const std::string& AsyncDataSourceFactoryBase::BuildRequest::url() const { | 108 const std::string& AsyncDataSourceFactoryBase::BuildRequest::url() const { |
109 return url_; | 109 return url_; |
110 } | 110 } |
111 | 111 |
112 } // namespace media | 112 } // namespace media |
OLD | NEW |