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

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.cc

Issue 14655012: SyncFS: Always normalize paths with FileSystemURL's ctor *and* GetNormalizedFilePath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sync_file_system/drive_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 const std::string& remote_resource_id, 1975 const std::string& remote_resource_id,
1976 int64 changestamp, 1976 int64 changestamp,
1977 const std::string& remote_file_md5, 1977 const std::string& remote_file_md5,
1978 const base::Time& updated_time, 1978 const base::Time& updated_time,
1979 SyncFileType file_type, 1979 SyncFileType file_type,
1980 RemoteSyncType sync_type) { 1980 RemoteSyncType sync_type) {
1981 fileapi::FileSystemURL url( 1981 fileapi::FileSystemURL url(
1982 CreateSyncableFileSystemURL(origin, kServiceName, path)); 1982 CreateSyncableFileSystemURL(origin, kServiceName, path));
1983 DCHECK(url.is_valid()); 1983 DCHECK(url.is_valid());
1984 1984
1985 // Note that we create a normalized path from url.path() rather than
1986 // path here (as FileSystemURL does extra normalization).
1987 base::FilePath::StringType normalized_path =
1988 fileapi::VirtualPath::GetNormalizedFilePath(url.path());
1989
1985 std::string local_resource_id; 1990 std::string local_resource_id;
1986 std::string local_file_md5; 1991 std::string local_file_md5;
1987 1992
1988 DriveMetadata metadata; 1993 DriveMetadata metadata;
1989 bool has_db_entry = 1994 bool has_db_entry =
1990 (metadata_store_->ReadEntry(url, &metadata) == SYNC_STATUS_OK); 1995 (metadata_store_->ReadEntry(url, &metadata) == SYNC_STATUS_OK);
1991 if (has_db_entry) { 1996 if (has_db_entry) {
1992 local_resource_id = metadata.resource_id(); 1997 local_resource_id = metadata.resource_id();
1993 if (!metadata.to_be_fetched()) 1998 if (!metadata.to_be_fetched())
1994 local_file_md5 = metadata.md5_checksum(); 1999 local_file_md5 = metadata.md5_checksum();
1995 } 2000 }
1996 2001
1997 PathToChangeMap* path_to_change = &origin_to_changes_map_[origin]; 2002 PathToChangeMap* path_to_change = &origin_to_changes_map_[origin];
1998 PathToChangeMap::iterator found = 2003 PathToChangeMap::iterator found = path_to_change->find(normalized_path);
1999 path_to_change->find(fileapi::VirtualPath::GetNormalizedFilePath(path));
2000 PendingChangeQueue::iterator overridden_queue_item = pending_changes_.end(); 2004 PendingChangeQueue::iterator overridden_queue_item = pending_changes_.end();
2001 if (found != path_to_change->end()) { 2005 if (found != path_to_change->end()) {
2002 if (found->second.changestamp >= changestamp) 2006 if (found->second.changestamp >= changestamp)
2003 return false; 2007 return false;
2004 const RemoteChange& pending_change = found->second; 2008 const RemoteChange& pending_change = found->second;
2005 overridden_queue_item = pending_change.position_in_queue; 2009 overridden_queue_item = pending_change.position_in_queue;
2006 2010
2007 if (pending_change.change.IsDelete()) { 2011 if (pending_change.change.IsDelete()) {
2008 local_resource_id.clear(); 2012 local_resource_id.clear();
2009 local_file_md5.clear(); 2013 local_file_md5.clear();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 2058
2055 // Do not return in this block. These changes should be done together. 2059 // Do not return in this block. These changes should be done together.
2056 { 2060 {
2057 if (overridden_queue_item != pending_changes_.end()) 2061 if (overridden_queue_item != pending_changes_.end())
2058 pending_changes_.erase(overridden_queue_item); 2062 pending_changes_.erase(overridden_queue_item);
2059 2063
2060 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue = 2064 std::pair<PendingChangeQueue::iterator, bool> inserted_to_queue =
2061 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url)); 2065 pending_changes_.insert(ChangeQueueItem(changestamp, sync_type, url));
2062 DCHECK(inserted_to_queue.second); 2066 DCHECK(inserted_to_queue.second);
2063 2067
2064 (*path_to_change)[fileapi::VirtualPath::GetNormalizedFilePath(path)] = 2068 (*path_to_change)[normalized_path] =
2065 RemoteChange( 2069 RemoteChange(
2066 changestamp, remote_resource_id, remote_file_md5, 2070 changestamp, remote_resource_id, remote_file_md5,
2067 updated_time, sync_type, url, file_change, 2071 updated_time, sync_type, url, file_change,
2068 inserted_to_queue.first); 2072 inserted_to_queue.first);
2069 } 2073 }
2070 2074
2071 DVLOG(3) << "Append remote change: " << path.value() 2075 DVLOG(3) << "Append remote change: " << path.value()
2076 << " (" << normalized_path << ")"
2072 << "@" << changestamp << " " 2077 << "@" << changestamp << " "
2073 << file_change.DebugString(); 2078 << file_change.DebugString();
2074 2079
2075 return true; 2080 return true;
2076 } 2081 }
2077 2082
2078 void DriveFileSyncService::RemoveRemoteChange( 2083 void DriveFileSyncService::RemoveRemoteChange(
2079 const FileSystemURL& url) { 2084 const FileSystemURL& url) {
2080 OriginToChangesMap::iterator found_origin = 2085 OriginToChangesMap::iterator found_origin =
2081 origin_to_changes_map_.find(url.origin()); 2086 origin_to_changes_map_.find(url.origin());
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 pending_batch_sync_origins_.insert(origin); 2416 pending_batch_sync_origins_.insert(origin);
2412 } 2417 }
2413 callback.Run(status, resource_id); 2418 callback.Run(status, resource_id);
2414 } 2419 }
2415 2420
2416 std::string DriveFileSyncService::sync_root_resource_id() { 2421 std::string DriveFileSyncService::sync_root_resource_id() {
2417 return metadata_store_->sync_root_directory(); 2422 return metadata_store_->sync_root_directory();
2418 } 2423 }
2419 2424
2420 } // namespace sync_file_system 2425 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698