Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / fileapi / fileapi_worker.cc
index 2ae6908..f172c4c 100644 (file)
@@ -66,19 +66,10 @@ void RunGetFileInfoCallback(const GetFileInfoCallback& callback,
   callback.Run(base::File::FILE_OK, file_info);
 }
 
-// Runs |callback| with arguments converted from |error| and |resource_entries|.
-void RunReadDirectoryCallback(
+// Runs |callback| with entries.
+void RunReadDirectoryCallbackWithEntries(
     const ReadDirectoryCallback& callback,
-    FileError error,
-    scoped_ptr<ResourceEntryVector> resource_entries,
-    bool has_more) {
-  if (error != FILE_ERROR_OK) {
-    DCHECK(!has_more);
-    callback.Run(FileErrorToBaseFileError(error),
-                 std::vector<fileapi::DirectoryEntry>(), has_more);
-    return;
-  }
-
+    scoped_ptr<ResourceEntryVector> resource_entries) {
   DCHECK(resource_entries);
 
   std::vector<fileapi::DirectoryEntry> entries;
@@ -97,7 +88,14 @@ void RunReadDirectoryCallback(
     entries.push_back(entry);
   }
 
-  callback.Run(base::File::FILE_OK, entries, has_more);
+  callback.Run(base::File::FILE_OK, entries, true /*has_more*/);
+}
+
+// Runs |callback| with |error|.
+void RunReadDirectoryCallbackOnCompletion(const ReadDirectoryCallback& callback,
+                                          FileError error) {
+  callback.Run(FileErrorToBaseFileError(error),
+               std::vector<fileapi::DirectoryEntry>(), false /*has_more*/);
 }
 
 // Runs |callback| with arguments based on |error|, |local_path| and |entry|.
@@ -265,8 +263,10 @@ void ReadDirectory(const base::FilePath& file_path,
                    const ReadDirectoryCallback& callback,
                    FileSystemInterface* file_system) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  file_system->ReadDirectory(file_path,
-                             base::Bind(&RunReadDirectoryCallback, callback));
+  file_system->ReadDirectory(
+      file_path,
+      base::Bind(&RunReadDirectoryCallbackWithEntries, callback),
+      base::Bind(&RunReadDirectoryCallbackOnCompletion, callback));
 }
 
 void Remove(const base::FilePath& file_path,