Commit a07edc75 authored by dcheng's avatar dcheng Committed by Commit bot

Media gallery fixups for scoped_refptr<T> operator T* removal.

BUG=110610

Review URL: https://codereview.chromium.org/518743002

Cr-Commit-Position: refs/heads/master@{#292664}
parent baf35970
......@@ -92,9 +92,10 @@ class MTPDeviceAsyncDelegate {
// Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the
// appropriate callback asynchronously when complete. Only valid when
// IsStreaming() is true.
virtual void ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
virtual void ReadBytes(const base::FilePath& device_file_path,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
......
......@@ -42,7 +42,7 @@ void CallInt64CompletionCallbackWithPlatformFileError(
void ReadBytes(
const storage::FileSystemURL& url,
net::IOBuffer* buf,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback,
......@@ -55,7 +55,7 @@ void ReadBytes(
delegate->ReadBytes(
url.path(),
make_scoped_refptr(buf),
buf,
offset,
buf_len,
success_callback,
......
......@@ -410,7 +410,9 @@ bool MTPDeviceDelegateImplLinux::IsStreaming() {
void MTPDeviceDelegateImplLinux::ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
......@@ -419,7 +421,7 @@ void MTPDeviceDelegateImplLinux::ReadBytes(
base::Bind(&MTPDeviceDelegateImplLinux::ReadBytesInternal,
weak_ptr_factory_.GetWeakPtr(),
device_file_path,
make_scoped_refptr(buf),
buf,
offset,
buf_len,
success_callback,
......
......@@ -85,9 +85,10 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
virtual void ReadBytes(const base::FilePath& device_file_path,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
......
......@@ -50,9 +50,10 @@ class MTPDeviceDelegateImplMac : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
virtual void ReadBytes(const base::FilePath& device_file_path,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
......
......@@ -201,7 +201,9 @@ bool MTPDeviceDelegateImplMac::IsStreaming() {
void MTPDeviceDelegateImplMac::ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
NOTREACHED();
......
......@@ -448,7 +448,9 @@ bool MTPDeviceDelegateImplWin::IsStreaming() {
void MTPDeviceDelegateImplWin::ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
NOTREACHED();
......
......@@ -104,9 +104,10 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes(
const base::FilePath& device_file_path,
net::IOBuffer* buf, int64 offset, int buf_len,
virtual void ReadBytes(const base::FilePath& device_file_path,
const scoped_refptr<net::IOBuffer>& buf,
int64 offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
......
......@@ -28,10 +28,13 @@ namespace {
const size_t kMaxBufferSize = 50 * 1024 * 1024; // Arbitrary maximum of 50MB.
typedef base::Callback<void(const scoped_refptr<net::DrainableIOBuffer>&)>
GotImageCallback;
void FinishGetImageBytes(
net::DrainableIOBuffer* buffer,
const scoped_refptr<net::DrainableIOBuffer>& buffer,
media::DataSource* source,
const base::Callback<void(net::DrainableIOBuffer*)>& callback,
const GotImageCallback& callback,
int bytes_read) {
if (bytes_read == media::DataSource::kReadError) {
callback.Run(NULL);
......@@ -41,20 +44,22 @@ void FinishGetImageBytes(
buffer->DidConsume(bytes_read);
// Didn't get the whole file. Continue reading to get the rest.
if (buffer->BytesRemaining() > 0) {
source->Read(0, buffer->BytesRemaining(),
source->Read(
0,
buffer->BytesRemaining(),
reinterpret_cast<uint8*>(buffer->data()),
base::Bind(&FinishGetImageBytes, make_scoped_refptr(buffer),
base::Unretained(source), callback));
base::Bind(
&FinishGetImageBytes, buffer, base::Unretained(source), callback));
return;
}
buffer->SetOffset(0);
callback.Run(make_scoped_refptr(buffer));
callback.Run(buffer);
}
void GetImageBytes(
media::DataSource* source,
const base::Callback<void(net::DrainableIOBuffer*)>& callback) {
const GotImageCallback& callback) {
int64 size64 = 0;
if (!source->GetSize(&size64) ||
base::saturated_cast<size_t>(size64) > kMaxBufferSize) {
......@@ -383,8 +388,9 @@ int ImageMetadataExtractor::iso_equivalent() const {
}
void ImageMetadataExtractor::FinishExtraction(
const DoneCallback& callback, net::DrainableIOBuffer* buffer) {
if (!buffer) {
const DoneCallback& callback,
const scoped_refptr<net::DrainableIOBuffer>& buffer) {
if (!buffer.get()) {
callback.Run(false);
return;
}
......
......@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
namespace media {
class DataSource;
......@@ -64,7 +65,7 @@ class ImageMetadataExtractor {
private:
// Second half of the Extract method.
void FinishExtraction(const DoneCallback& callback,
net::DrainableIOBuffer* buffer);
const scoped_refptr<net::DrainableIOBuffer>& buffer);
bool extracted_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment