Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / file_system / download_operation.cc
index ba89f00..bf948cf 100644 (file)
@@ -8,15 +8,14 @@
 #include "base/file_util.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/strings/stringprintf.h"
 #include "base/task_runner_util.h"
 #include "chrome/browser/chromeos/drive/drive.pb.h"
 #include "chrome/browser/chromeos/drive/file_cache.h"
+#include "chrome/browser/chromeos/drive/file_change.h"
 #include "chrome/browser/chromeos/drive/file_errors.h"
-#include "chrome/browser/chromeos/drive/file_system/operation_observer.h"
+#include "chrome/browser/chromeos/drive/file_system/operation_delegate.h"
 #include "chrome/browser/chromeos/drive/file_system_util.h"
 #include "chrome/browser/chromeos/drive/job_scheduler.h"
-#include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
 #include "chrome/browser/chromeos/drive/resource_metadata.h"
 #include "content/public/browser/browser_thread.h"
 #include "google_apis/drive/gdata_errorcode.h"
@@ -98,7 +97,6 @@ FileError CheckPreConditionForEnsureFileDownloaded(
     base::FilePath::StringType extension = base::FilePath::FromUTF8Unsafe(
         entry->file_specific_info().document_extension()).value();
     base::FilePath gdoc_file_path;
-    // TODO(rvargas): Convert this code to use base::File::Info.
     base::File::Info file_info;
     // We add the gdoc file extension in the temporary file, so that in cross
     // profile drag-and-drop between Drive folders, the destination profiles's
@@ -339,13 +337,13 @@ class DownloadOperation::DownloadParams {
 
 DownloadOperation::DownloadOperation(
     base::SequencedTaskRunner* blocking_task_runner,
-    OperationObserver* observer,
+    OperationDelegate* delegate,
     JobScheduler* scheduler,
     internal::ResourceMetadata* metadata,
     internal::FileCache* cache,
     const base::FilePath& temporary_file_directory)
     : blocking_task_runner_(blocking_task_runner),
-      observer_(observer),
+      delegate_(delegate),
       scheduler_(scheduler),
       metadata_(metadata),
       cache_(cache),
@@ -527,9 +525,13 @@ void DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState(
     params->OnError(error);
     return;
   }
+  DCHECK(!entry_after_update->file_info().is_directory());
 
+  FileChange changed_files;
+  changed_files.Update(
+      file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
   // Storing to cache changes the "offline available" status, hence notify.
-  observer_->OnDirectoryChangedByOperation(file_path.DirName());
+  delegate_->OnFileChangedByOperation(changed_files);
   params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass());
 }