OLD | NEW |
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_change.h" | 5 #include "chrome/browser/chromeos/drive/file_change.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 void FileChange::Update(const base::FilePath file_path, | 109 void FileChange::Update(const base::FilePath file_path, |
110 FileType file_type, | 110 FileType file_type, |
111 FileChange::ChangeType change) { | 111 FileChange::ChangeType change) { |
112 Update(file_path, FileChange::Change(change, file_type)); | 112 Update(file_path, FileChange::Change(change, file_type)); |
113 } | 113 } |
114 | 114 |
115 void FileChange::Update(const base::FilePath file_path, | 115 void FileChange::Update(const base::FilePath file_path, |
116 const ResourceEntry& entry, | 116 const ResourceEntry& entry, |
117 FileChange::ChangeType change) { | 117 FileChange::ChangeType change) { |
118 FileType type = | 118 FileType type = !entry.has_file_info() |
119 entry.deleted() ? FILE_TYPE_UNKNOWN : entry.file_info().is_directory() | 119 ? FILE_TYPE_UNKNOWN |
120 ? FILE_TYPE_DIRECTORY | 120 : entry.file_info().is_directory() ? FILE_TYPE_DIRECTORY |
121 : FILE_TYPE_FILE; | 121 : FILE_TYPE_FILE; |
| 122 |
122 Update(file_path, type, change); | 123 Update(file_path, type, change); |
123 } | 124 } |
124 | 125 |
125 void FileChange::Apply(const FileChange& new_changed_files) { | 126 void FileChange::Apply(const FileChange& new_changed_files) { |
126 for (Map::const_iterator it = new_changed_files.map().begin(); | 127 for (Map::const_iterator it = new_changed_files.map().begin(); |
127 it != new_changed_files.map().end(); | 128 it != new_changed_files.map().end(); |
128 it++) { | 129 it++) { |
129 Update(it->first, it->second); | 130 Update(it->first, it->second); |
130 } | 131 } |
131 } | 132 } |
(...skipping 12 matching lines...) Expand all Loading... |
144 ss << "{ "; | 145 ss << "{ "; |
145 for (FileChange::Map::const_iterator it = map_.begin(); it != map_.end(); | 146 for (FileChange::Map::const_iterator it = map_.begin(); it != map_.end(); |
146 it++) { | 147 it++) { |
147 ss << it->first.value() << ": " << it->second.DebugString() << ", "; | 148 ss << it->first.value() << ": " << it->second.DebugString() << ", "; |
148 } | 149 } |
149 ss << "}"; | 150 ss << "}"; |
150 return ss.str(); | 151 return ss.str(); |
151 } | 152 } |
152 | 153 |
153 } // namespace drive | 154 } // namespace drive |
OLD | NEW |