Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / media_galleries / win / mtp_device_delegate_impl_win.cc
index 56a121c..0ff745a 100644 (file)
@@ -29,7 +29,7 @@
 #include "chrome/browser/media_galleries/win/snapshot_file_details.h"
 #include "components/storage_monitor/storage_monitor.h"
 #include "content/public/browser/browser_thread.h"
-#include "webkit/common/fileapi/file_system_util.h"
+#include "storage/common/fileapi/file_system_util.h"
 
 namespace {
 
@@ -39,7 +39,7 @@ namespace {
 bool GetStorageInfoOnUIThread(const base::string16& storage_path,
                               base::string16* pnp_device_id,
                               base::string16* storage_object_id) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
   DCHECK(!storage_path.empty());
   DCHECK(pnp_device_id);
   DCHECK(storage_object_id);
@@ -47,7 +47,8 @@ bool GetStorageInfoOnUIThread(const base::string16& storage_path,
   base::RemoveChars(storage_path, L"\\\\", &storage_device_id);
   DCHECK(!storage_device_id.empty());
   // TODO(gbillock): Take the StorageMonitor as an argument.
-  StorageMonitor* monitor = StorageMonitor::GetInstance();
+  storage_monitor::StorageMonitor* monitor =
+      storage_monitor::StorageMonitor::GetInstance();
   DCHECK(monitor);
   return monitor->GetMTPStorageInfoFromDeviceId(
       base::UTF16ToUTF8(storage_device_id), pnp_device_id, storage_object_id);
@@ -179,7 +180,7 @@ base::File::Error GetFileInfoOnBlockingPoolThread(
 base::File::Error ReadDirectoryOnBlockingPoolThread(
     const MTPDeviceDelegateImplWin::StorageDeviceInfo& device_info,
     const base::FilePath& root,
-    fileapi::AsyncFileUtil::EntryList* entries) {
+    storage::AsyncFileUtil::EntryList* entries) {
   base::ThreadRestrictions::AssertIOAllowed();
   DCHECK(!root.empty());
   DCHECK(entries);
@@ -199,9 +200,9 @@ base::File::Error ReadDirectoryOnBlockingPoolThread(
     return error;
 
   while (!(current = file_enum->Next()).empty()) {
-    fileapi::DirectoryEntry entry;
+    storage::DirectoryEntry entry;
     entry.is_directory = file_enum->IsDirectory();
-    entry.name = fileapi::VirtualPath::BaseName(current).value();
+    entry.name = storage::VirtualPath::BaseName(current).value();
     entry.size = file_enum->Size();
     entry.last_modified_time = file_enum->LastModifiedTime();
     entries->push_back(entry);
@@ -302,7 +303,7 @@ void OnGetStorageInfoCreateDelegate(
     base::string16* pnp_device_id,
     base::string16* storage_object_id,
     bool succeeded) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(pnp_device_id);
   DCHECK(storage_object_id);
   if (!succeeded)
@@ -315,7 +316,7 @@ void OnGetStorageInfoCreateDelegate(
 void CreateMTPDeviceAsyncDelegate(
     const base::string16& device_location,
     const CreateMTPDeviceAsyncDelegateCallback& callback) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!device_location.empty());
   base::string16* pnp_device_id = new base::string16;
   base::string16* storage_object_id = new base::string16;
@@ -342,7 +343,7 @@ MTPDeviceDelegateImplWin::StorageDeviceInfo::StorageDeviceInfo(
     : pnp_device_id(pnp_device_id),
       registered_device_path(registered_device_path),
       storage_object_id(storage_object_id) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
 }
 
 MTPDeviceDelegateImplWin::PendingTaskInfo::PendingTaskInfo(
@@ -364,7 +365,7 @@ MTPDeviceDelegateImplWin::MTPDeviceDelegateImplWin(
       media_task_runner_(MediaFileSystemBackend::MediaTaskRunner()),
       task_in_progress_(false),
       weak_ptr_factory_(this) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!registered_device_path.empty());
   DCHECK(!pnp_device_id.empty());
   DCHECK(!storage_object_id.empty());
@@ -372,14 +373,14 @@ MTPDeviceDelegateImplWin::MTPDeviceDelegateImplWin(
 }
 
 MTPDeviceDelegateImplWin::~MTPDeviceDelegateImplWin() {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
 }
 
 void MTPDeviceDelegateImplWin::GetFileInfo(
     const base::FilePath& file_path,
     const GetFileInfoSuccessCallback& success_callback,
     const ErrorCallback& error_callback) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!file_path.empty());
   base::File::Info* file_info = new base::File::Info;
   EnsureInitAndRunTask(
@@ -399,10 +400,10 @@ void MTPDeviceDelegateImplWin::ReadDirectory(
     const base::FilePath& root,
     const ReadDirectorySuccessCallback& success_callback,
     const ErrorCallback& error_callback) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!root.empty());
-  fileapi::AsyncFileUtil::EntryList* entries =
-      new fileapi::AsyncFileUtil::EntryList;
+  storage::AsyncFileUtil::EntryList* entries =
+      new storage::AsyncFileUtil::EntryList;
   EnsureInitAndRunTask(
       PendingTaskInfo(FROM_HERE,
                       base::Bind(&ReadDirectoryOnBlockingPoolThread,
@@ -421,7 +422,7 @@ void MTPDeviceDelegateImplWin::CreateSnapshotFile(
     const base::FilePath& snapshot_file_path,
     const CreateSnapshotFileSuccessCallback& success_callback,
     const ErrorCallback& error_callback) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!device_file_path.empty());
   DCHECK(!snapshot_file_path.empty());
   scoped_ptr<SnapshotFileDetails> file_details(
@@ -447,14 +448,16 @@ 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();
 }
 
 void MTPDeviceDelegateImplWin::CancelPendingTasksAndDeleteDelegate() {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   PortableDeviceMapService::GetInstance()->MarkPortableDeviceForDeletion(
       storage_device_info_.registered_device_path);
   media_task_runner_->PostTask(
@@ -468,7 +471,7 @@ void MTPDeviceDelegateImplWin::CancelPendingTasksAndDeleteDelegate() {
 
 void MTPDeviceDelegateImplWin::EnsureInitAndRunTask(
     const PendingTaskInfo& task_info) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   if ((init_state_ == INITIALIZED) && !task_in_progress_) {
     DCHECK(pending_tasks_.empty());
     DCHECK(!current_snapshot_details_.get());
@@ -521,7 +524,7 @@ void MTPDeviceDelegateImplWin::ProcessNextPendingRequest() {
 }
 
 void MTPDeviceDelegateImplWin::OnInitCompleted(bool succeeded) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   init_state_ = succeeded ? INITIALIZED : UNINITIALIZED;
   task_in_progress_ = false;
   ProcessNextPendingRequest();
@@ -532,7 +535,7 @@ void MTPDeviceDelegateImplWin::OnGetFileInfo(
     const ErrorCallback& error_callback,
     base::File::Info* file_info,
     base::File::Error error) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(file_info);
   if (error == base::File::FILE_OK)
     success_callback.Run(*file_info);
@@ -545,9 +548,9 @@ void MTPDeviceDelegateImplWin::OnGetFileInfo(
 void MTPDeviceDelegateImplWin::OnDidReadDirectory(
     const ReadDirectorySuccessCallback& success_callback,
     const ErrorCallback& error_callback,
-    fileapi::AsyncFileUtil::EntryList* file_list,
+    storage::AsyncFileUtil::EntryList* file_list,
     base::File::Error error) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(file_list);
   if (error == base::File::FILE_OK)
     success_callback.Run(*file_list, false /*no more entries*/);
@@ -560,7 +563,7 @@ void MTPDeviceDelegateImplWin::OnDidReadDirectory(
 void MTPDeviceDelegateImplWin::OnGetFileStream(
     scoped_ptr<SnapshotFileDetails> file_details,
     base::File::Error error) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(file_details);
   DCHECK(!file_details->request_info().device_file_path.empty());
   DCHECK(!file_details->request_info().snapshot_file_path.empty());
@@ -580,7 +583,7 @@ void MTPDeviceDelegateImplWin::OnGetFileStream(
 void MTPDeviceDelegateImplWin::OnWroteDataChunkIntoSnapshotFile(
     const base::FilePath& snapshot_file_path,
     DWORD bytes_written) {
-  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+  DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
   DCHECK(!snapshot_file_path.empty());
   if (!current_snapshot_details_.get())
     return;