Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: chrome/browser/chromeos/drive/file_system/touch_operation.cc

Issue 343073003: Files.app: Provide detailed change information on onDirectoryChanged event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/file_system/touch_operation.cc
diff --git a/chrome/browser/chromeos/drive/file_system/touch_operation.cc b/chrome/browser/chromeos/drive/file_system/touch_operation.cc
index bb1b23dde33d75581647c5c7448649206b722648..9e2dd62771cf3c2798f09a9bd3e15623e1baf03b 100644
--- a/chrome/browser/chromeos/drive/file_system/touch_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/touch_operation.cc
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/sequenced_task_runner.h"
#include "base/time/time.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/resource_metadata.h"
@@ -25,21 +26,21 @@ FileError UpdateLocalState(internal::ResourceMetadata* metadata,
const base::FilePath& file_path,
const base::Time& last_access_time,
const base::Time& last_modified_time,
- std::string* local_id) {
- ResourceEntry entry;
- FileError error = metadata->GetResourceEntryByPath(file_path, &entry);
+ ResourceEntry* entry,
+ std::string* local_id) {
+ FileError error = metadata->GetResourceEntryByPath(file_path, entry);
if (error != FILE_ERROR_OK)
return error;
- *local_id = entry.local_id();
+ *local_id = entry->local_id();
- PlatformFileInfoProto* file_info = entry.mutable_file_info();
+ PlatformFileInfoProto* file_info = entry->mutable_file_info();
if (!last_access_time.is_null())
file_info->set_last_accessed(last_access_time.ToInternalValue());
if (!last_modified_time.is_null())
file_info->set_last_modified(last_modified_time.ToInternalValue());
- entry.set_metadata_edit_state(ResourceEntry::DIRTY);
- entry.set_modification_date(base::Time::Now().ToInternalValue());
- return metadata->RefreshEntry(entry);
+ entry->set_metadata_edit_state(ResourceEntry::DIRTY);
+ entry->set_modification_date(base::Time::Now().ToInternalValue());
+ return metadata->RefreshEntry(*entry);
}
} // namespace
@@ -64,6 +65,7 @@ void TouchOperation::TouchFile(const base::FilePath& file_path,
DCHECK(!callback.is_null());
std::string* local_id = new std::string;
+ ResourceEntry* entry = new ResourceEntry;
base::PostTaskAndReplyWithResult(
blocking_task_runner_.get(),
FROM_HERE,
@@ -72,24 +74,32 @@ void TouchOperation::TouchFile(const base::FilePath& file_path,
file_path,
last_access_time,
last_modified_time,
+ entry,
local_id),
base::Bind(&TouchOperation::TouchFileAfterUpdateLocalState,
weak_ptr_factory_.GetWeakPtr(),
file_path,
callback,
+ base::Owned(entry),
base::Owned(local_id)));
}
void TouchOperation::TouchFileAfterUpdateLocalState(
const base::FilePath& file_path,
const FileOperationCallback& callback,
+ const ResourceEntry* entry,
const std::string* local_id,
FileError error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
+ DCHECK(!entry->file_info().is_directory());
+
+ FileChange changed_files;
+ changed_files.Update(
+ file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
if (error == FILE_ERROR_OK) {
- observer_->OnDirectoryChangedByOperation(file_path.DirName());
+ observer_->OnFileChangedByOperation(changed_files);
observer_->OnEntryUpdatedByOperation(*local_id);
}
callback.Run(error);

Powered by Google App Engine
This is Rietveld 408576698