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,11 +92,12 @@ class MTPDeviceAsyncDelegate { ...@@ -92,11 +92,12 @@ class MTPDeviceAsyncDelegate {
// Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the // Reads up to |buf_len| bytes from |device_file_path| into |buf|. Invokes the
// appropriate callback asynchronously when complete. Only valid when // appropriate callback asynchronously when complete. Only valid when
// IsStreaming() is true. // IsStreaming() is true.
virtual void ReadBytes( virtual void ReadBytes(const base::FilePath& device_file_path,
const base::FilePath& device_file_path, const scoped_refptr<net::IOBuffer>& buf,
net::IOBuffer* buf, int64 offset, int buf_len, int64 offset,
const ReadBytesSuccessCallback& success_callback, int buf_len,
const ErrorCallback& error_callback) = 0; const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) = 0;
// Called when the // Called when the
// (1) Browser application is in shutdown mode (or) // (1) Browser application is in shutdown mode (or)
......
...@@ -42,7 +42,7 @@ void CallInt64CompletionCallbackWithPlatformFileError( ...@@ -42,7 +42,7 @@ void CallInt64CompletionCallbackWithPlatformFileError(
void ReadBytes( void ReadBytes(
const storage::FileSystemURL& url, const storage::FileSystemURL& url,
net::IOBuffer* buf, const scoped_refptr<net::IOBuffer>& buf,
int64 offset, int64 offset,
int buf_len, int buf_len,
const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback, const MTPDeviceAsyncDelegate::ReadBytesSuccessCallback& success_callback,
...@@ -55,7 +55,7 @@ void ReadBytes( ...@@ -55,7 +55,7 @@ void ReadBytes(
delegate->ReadBytes( delegate->ReadBytes(
url.path(), url.path(),
make_scoped_refptr(buf), buf,
offset, offset,
buf_len, buf_len,
success_callback, success_callback,
......
...@@ -410,7 +410,9 @@ bool MTPDeviceDelegateImplLinux::IsStreaming() { ...@@ -410,7 +410,9 @@ bool MTPDeviceDelegateImplLinux::IsStreaming() {
void MTPDeviceDelegateImplLinux::ReadBytes( void MTPDeviceDelegateImplLinux::ReadBytes(
const base::FilePath& device_file_path, 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 ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
...@@ -419,7 +421,7 @@ void MTPDeviceDelegateImplLinux::ReadBytes( ...@@ -419,7 +421,7 @@ void MTPDeviceDelegateImplLinux::ReadBytes(
base::Bind(&MTPDeviceDelegateImplLinux::ReadBytesInternal, base::Bind(&MTPDeviceDelegateImplLinux::ReadBytesInternal,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
device_file_path, device_file_path,
make_scoped_refptr(buf), buf,
offset, offset,
buf_len, buf_len,
success_callback, success_callback,
......
...@@ -85,11 +85,12 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate { ...@@ -85,11 +85,12 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback, const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE; const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE; virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes( virtual void ReadBytes(const base::FilePath& device_file_path,
const base::FilePath& device_file_path, const scoped_refptr<net::IOBuffer>& buf,
net::IOBuffer* buf, int64 offset, int buf_len, int64 offset,
const ReadBytesSuccessCallback& success_callback, int buf_len,
const ErrorCallback& error_callback) OVERRIDE; const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
// The internal methods correspond to the similarly named methods above. // The internal methods correspond to the similarly named methods above.
......
...@@ -50,11 +50,12 @@ class MTPDeviceDelegateImplMac : public MTPDeviceAsyncDelegate { ...@@ -50,11 +50,12 @@ class MTPDeviceDelegateImplMac : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback, const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE; const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE; virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes( virtual void ReadBytes(const base::FilePath& device_file_path,
const base::FilePath& device_file_path, const scoped_refptr<net::IOBuffer>& buf,
net::IOBuffer* buf, int64 offset, int buf_len, int64 offset,
const ReadBytesSuccessCallback& success_callback, int buf_len,
const ErrorCallback& error_callback) OVERRIDE; const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
// Forward delegates for ImageCaptureDeviceListener. These are // Forward delegates for ImageCaptureDeviceListener. These are
......
...@@ -201,7 +201,9 @@ bool MTPDeviceDelegateImplMac::IsStreaming() { ...@@ -201,7 +201,9 @@ bool MTPDeviceDelegateImplMac::IsStreaming() {
void MTPDeviceDelegateImplMac::ReadBytes( void MTPDeviceDelegateImplMac::ReadBytes(
const base::FilePath& device_file_path, 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 ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
NOTREACHED(); NOTREACHED();
......
...@@ -448,7 +448,9 @@ bool MTPDeviceDelegateImplWin::IsStreaming() { ...@@ -448,7 +448,9 @@ bool MTPDeviceDelegateImplWin::IsStreaming() {
void MTPDeviceDelegateImplWin::ReadBytes( void MTPDeviceDelegateImplWin::ReadBytes(
const base::FilePath& device_file_path, 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 ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) { const ErrorCallback& error_callback) {
NOTREACHED(); NOTREACHED();
......
...@@ -104,11 +104,12 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate { ...@@ -104,11 +104,12 @@ class MTPDeviceDelegateImplWin : public MTPDeviceAsyncDelegate {
const CreateSnapshotFileSuccessCallback& success_callback, const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE; const ErrorCallback& error_callback) OVERRIDE;
virtual bool IsStreaming() OVERRIDE; virtual bool IsStreaming() OVERRIDE;
virtual void ReadBytes( virtual void ReadBytes(const base::FilePath& device_file_path,
const base::FilePath& device_file_path, const scoped_refptr<net::IOBuffer>& buf,
net::IOBuffer* buf, int64 offset, int buf_len, int64 offset,
const ReadBytesSuccessCallback& success_callback, int buf_len,
const ErrorCallback& error_callback) OVERRIDE; const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
// Ensures the device is initialized for communication by doing a // Ensures the device is initialized for communication by doing a
......
...@@ -28,10 +28,13 @@ namespace { ...@@ -28,10 +28,13 @@ namespace {
const size_t kMaxBufferSize = 50 * 1024 * 1024; // Arbitrary maximum of 50MB. const size_t kMaxBufferSize = 50 * 1024 * 1024; // Arbitrary maximum of 50MB.
typedef base::Callback<void(const scoped_refptr<net::DrainableIOBuffer>&)>
GotImageCallback;
void FinishGetImageBytes( void FinishGetImageBytes(
net::DrainableIOBuffer* buffer, const scoped_refptr<net::DrainableIOBuffer>& buffer,
media::DataSource* source, media::DataSource* source,
const base::Callback<void(net::DrainableIOBuffer*)>& callback, const GotImageCallback& callback,
int bytes_read) { int bytes_read) {
if (bytes_read == media::DataSource::kReadError) { if (bytes_read == media::DataSource::kReadError) {
callback.Run(NULL); callback.Run(NULL);
...@@ -41,20 +44,22 @@ void FinishGetImageBytes( ...@@ -41,20 +44,22 @@ void FinishGetImageBytes(
buffer->DidConsume(bytes_read); buffer->DidConsume(bytes_read);
// Didn't get the whole file. Continue reading to get the rest. // Didn't get the whole file. Continue reading to get the rest.
if (buffer->BytesRemaining() > 0) { if (buffer->BytesRemaining() > 0) {
source->Read(0, buffer->BytesRemaining(), source->Read(
reinterpret_cast<uint8*>(buffer->data()), 0,
base::Bind(&FinishGetImageBytes, make_scoped_refptr(buffer), buffer->BytesRemaining(),
base::Unretained(source), callback)); reinterpret_cast<uint8*>(buffer->data()),
base::Bind(
&FinishGetImageBytes, buffer, base::Unretained(source), callback));
return; return;
} }
buffer->SetOffset(0); buffer->SetOffset(0);
callback.Run(make_scoped_refptr(buffer)); callback.Run(buffer);
} }
void GetImageBytes( void GetImageBytes(
media::DataSource* source, media::DataSource* source,
const base::Callback<void(net::DrainableIOBuffer*)>& callback) { const GotImageCallback& callback) {
int64 size64 = 0; int64 size64 = 0;
if (!source->GetSize(&size64) || if (!source->GetSize(&size64) ||
base::saturated_cast<size_t>(size64) > kMaxBufferSize) { base::saturated_cast<size_t>(size64) > kMaxBufferSize) {
...@@ -383,8 +388,9 @@ int ImageMetadataExtractor::iso_equivalent() const { ...@@ -383,8 +388,9 @@ int ImageMetadataExtractor::iso_equivalent() const {
} }
void ImageMetadataExtractor::FinishExtraction( void ImageMetadataExtractor::FinishExtraction(
const DoneCallback& callback, net::DrainableIOBuffer* buffer) { const DoneCallback& callback,
if (!buffer) { const scoped_refptr<net::DrainableIOBuffer>& buffer) {
if (!buffer.get()) {
callback.Run(false); callback.Run(false);
return; return;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
namespace media { namespace media {
class DataSource; class DataSource;
...@@ -64,7 +65,7 @@ class ImageMetadataExtractor { ...@@ -64,7 +65,7 @@ class ImageMetadataExtractor {
private: private:
// Second half of the Extract method. // Second half of the Extract method.
void FinishExtraction(const DoneCallback& callback, void FinishExtraction(const DoneCallback& callback,
net::DrainableIOBuffer* buffer); const scoped_refptr<net::DrainableIOBuffer>& buffer);
bool extracted_; 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