OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/multibuffer_data_source.h" | 5 #include "media/blink/multibuffer_data_source.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 class MultibufferDataSource::ReadOperation { | 58 class MultibufferDataSource::ReadOperation { |
59 public: | 59 public: |
60 ReadOperation(int64_t position, | 60 ReadOperation(int64_t position, |
61 int size, | 61 int size, |
62 uint8_t* data, | 62 uint8_t* data, |
63 const DataSource::ReadCB& callback); | 63 const DataSource::ReadCB& callback); |
64 ~ReadOperation(); | 64 ~ReadOperation(); |
65 | 65 |
66 // Runs |callback_| with the given |result|, deleting the operation | 66 // Runs |callback_| with the given |result|, deleting the operation |
67 // afterwards. | 67 // afterwards. |
68 static void Run(scoped_ptr<ReadOperation> read_op, int result); | 68 static void Run(std::unique_ptr<ReadOperation> read_op, int result); |
69 | 69 |
70 int64_t position() { return position_; } | 70 int64_t position() { return position_; } |
71 int size() { return size_; } | 71 int size() { return size_; } |
72 uint8_t* data() { return data_; } | 72 uint8_t* data() { return data_; } |
73 | 73 |
74 private: | 74 private: |
75 const int64_t position_; | 75 const int64_t position_; |
76 const int size_; | 76 const int size_; |
77 uint8_t* data_; | 77 uint8_t* data_; |
78 DataSource::ReadCB callback_; | 78 DataSource::ReadCB callback_; |
79 | 79 |
80 DISALLOW_IMPLICIT_CONSTRUCTORS(ReadOperation); | 80 DISALLOW_IMPLICIT_CONSTRUCTORS(ReadOperation); |
81 }; | 81 }; |
82 | 82 |
83 MultibufferDataSource::ReadOperation::ReadOperation( | 83 MultibufferDataSource::ReadOperation::ReadOperation( |
84 int64_t position, | 84 int64_t position, |
85 int size, | 85 int size, |
86 uint8_t* data, | 86 uint8_t* data, |
87 const DataSource::ReadCB& callback) | 87 const DataSource::ReadCB& callback) |
88 : position_(position), size_(size), data_(data), callback_(callback) { | 88 : position_(position), size_(size), data_(data), callback_(callback) { |
89 DCHECK(!callback_.is_null()); | 89 DCHECK(!callback_.is_null()); |
90 } | 90 } |
91 | 91 |
92 MultibufferDataSource::ReadOperation::~ReadOperation() { | 92 MultibufferDataSource::ReadOperation::~ReadOperation() { |
93 DCHECK(callback_.is_null()); | 93 DCHECK(callback_.is_null()); |
94 } | 94 } |
95 | 95 |
96 // static | 96 // static |
97 void MultibufferDataSource::ReadOperation::Run( | 97 void MultibufferDataSource::ReadOperation::Run( |
98 scoped_ptr<ReadOperation> read_op, | 98 std::unique_ptr<ReadOperation> read_op, |
99 int result) { | 99 int result) { |
100 base::ResetAndReturn(&read_op->callback_).Run(result); | 100 base::ResetAndReturn(&read_op->callback_).Run(result); |
101 } | 101 } |
102 | 102 |
103 MultibufferDataSource::MultibufferDataSource( | 103 MultibufferDataSource::MultibufferDataSource( |
104 const GURL& url, | 104 const GURL& url, |
105 UrlData::CORSMode cors_mode, | 105 UrlData::CORSMode cors_mode, |
106 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 106 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
107 linked_ptr<UrlIndex> url_index, | 107 linked_ptr<UrlIndex> url_index, |
108 WebFrame* frame, | 108 WebFrame* frame, |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 reader_->SetMaxBuffer(back_buffer, preload + kPreloadHighExtra); | 574 reader_->SetMaxBuffer(back_buffer, preload + kPreloadHighExtra); |
575 | 575 |
576 if (preload_ == METADATA) { | 576 if (preload_ == METADATA) { |
577 reader_->SetPreload(0, 0); | 577 reader_->SetPreload(0, 0); |
578 } else { | 578 } else { |
579 reader_->SetPreload(preload + kPreloadHighExtra, preload); | 579 reader_->SetPreload(preload + kPreloadHighExtra, preload); |
580 } | 580 } |
581 } | 581 } |
582 | 582 |
583 } // namespace media | 583 } // namespace media |
OLD | NEW |