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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/update_operation.cc

Issue 139783004: drive: Do not clear dirty bit if someone is writing to the file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/update_operation.h"
6 6
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "chrome/browser/chromeos/drive/drive.pb.h" 8 #include "chrome/browser/chromeos/drive/drive.pb.h"
9 #include "chrome/browser/chromeos/drive/file_cache.h" 9 #include "chrome/browser/chromeos/drive/file_cache.h"
10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 10 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 entry.set_parent_local_id(existing_entry.parent_local_id()); 88 entry.set_parent_local_id(existing_entry.parent_local_id());
89 89
90 error = metadata->RefreshEntry(entry); 90 error = metadata->RefreshEntry(entry);
91 if (error != FILE_ERROR_OK) 91 if (error != FILE_ERROR_OK)
92 return error; 92 return error;
93 93
94 *drive_file_path = metadata->GetFilePath(local_id); 94 *drive_file_path = metadata->GetFilePath(local_id);
95 if (drive_file_path->empty()) 95 if (drive_file_path->empty())
96 return FILE_ERROR_NOT_FOUND; 96 return FILE_ERROR_NOT_FOUND;
97 97
98 // Clear the dirty bit if we have updated an existing file. 98 // Do not clear the dirty bit if someone is writing to the file.
99 if (cache->IsOpenedForWrite(local_id))
100 return FILE_ERROR_OK;
99 return cache->ClearDirty(local_id, entry.file_specific_info().md5()); 101 return cache->ClearDirty(local_id, entry.file_specific_info().md5());
100 } 102 }
101 103
102 } // namespace 104 } // namespace
103 105
104 UpdateOperation::UpdateOperation( 106 UpdateOperation::UpdateOperation(
105 base::SequencedTaskRunner* blocking_task_runner, 107 base::SequencedTaskRunner* blocking_task_runner,
106 OperationObserver* observer, 108 OperationObserver* observer,
107 JobScheduler* scheduler, 109 JobScheduler* scheduler,
108 internal::ResourceMetadata* metadata, 110 internal::ResourceMetadata* metadata,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (error != FILE_ERROR_OK) { 213 if (error != FILE_ERROR_OK) {
212 callback.Run(error); 214 callback.Run(error);
213 return; 215 return;
214 } 216 }
215 observer_->OnDirectoryChangedByOperation(drive_file_path->DirName()); 217 observer_->OnDirectoryChangedByOperation(drive_file_path->DirName());
216 callback.Run(FILE_ERROR_OK); 218 callback.Run(FILE_ERROR_OK);
217 } 219 }
218 220
219 } // namespace file_system 221 } // namespace file_system
220 } // namespace drive 222 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698