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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.cc

Issue 10854199: ResourceId and unit test cleanup. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: minor Created 8 years, 4 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 <utility>
6
5 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
6 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" 8 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h"
7 #include "chrome/browser/chromeos/gdata/gdata_files.h" 9 #include "chrome/browser/chromeos/gdata/gdata_files.h"
8 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h" 10 #include "chrome/browser/chromeos/gdata/gdata_wapi_feed_processor.h"
9 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
10 12
11 using content::BrowserThread; 13 using content::BrowserThread;
12 14
13 namespace gdata { 15 namespace gdata {
14 16
15 namespace {
16
17 // Recursively extracts the paths set of all sub-directories of |entry|.
18 void GetChildDirectoryPaths(GDataEntry* entry,
19 std::set<FilePath>* changed_dirs) {
20 GDataDirectory* dir = entry->AsGDataDirectory();
21 if (!dir)
22 return;
23
24 for (GDataDirectoryCollection::const_iterator it =
25 dir->child_directories().begin();
26 it != dir->child_directories().end(); ++it) {
27 GDataDirectory* child_dir = it->second;
28 changed_dirs->insert(child_dir->GetFilePath());
29 GetChildDirectoryPaths(child_dir, changed_dirs);
30 }
31 }
32
33 } // namespace
34
35 FeedToFileResourceMapUmaStats::FeedToFileResourceMapUmaStats() 17 FeedToFileResourceMapUmaStats::FeedToFileResourceMapUmaStats()
36 : num_regular_files(0), 18 : num_regular_files(0),
37 num_hosted_documents(0) { 19 num_hosted_documents(0) {
38 } 20 }
39 21
40 FeedToFileResourceMapUmaStats::~FeedToFileResourceMapUmaStats() { 22 FeedToFileResourceMapUmaStats::~FeedToFileResourceMapUmaStats() {
41 } 23 }
42 24
43 GDataWapiFeedProcessor::GDataWapiFeedProcessor( 25 GDataWapiFeedProcessor::GDataWapiFeedProcessor(
44 GDataDirectoryService* directory_service) 26 GDataDirectoryService* directory_service)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 193 }
212 194
213 // static 195 // static
214 void GDataWapiFeedProcessor:: 196 void GDataWapiFeedProcessor::
215 RemoveEntryFromDirectoryAndCollectChangedDirectories( 197 RemoveEntryFromDirectoryAndCollectChangedDirectories(
216 GDataDirectory* directory, 198 GDataDirectory* directory,
217 GDataEntry* entry, 199 GDataEntry* entry,
218 std::set<FilePath>* changed_dirs) { 200 std::set<FilePath>* changed_dirs) {
219 // Get the list of all sub-directory paths, so we can notify their listeners 201 // Get the list of all sub-directory paths, so we can notify their listeners
220 // that they are smoked. 202 // that they are smoked.
221 GetChildDirectoryPaths(entry, changed_dirs); 203 GDataDirectory* dir = entry->AsGDataDirectory();
204 if (dir)
205 dir->GetChildDirectoryPaths(changed_dirs);
222 directory->RemoveEntry(entry); 206 directory->RemoveEntry(entry);
223 } 207 }
224 208
225 GDataDirectory* GDataWapiFeedProcessor::FindDirectoryForNewEntry( 209 GDataDirectory* GDataWapiFeedProcessor::FindDirectoryForNewEntry(
226 GDataEntry* new_entry, 210 GDataEntry* new_entry,
227 const FileResourceIdMap& file_map, 211 const FileResourceIdMap& file_map,
228 GDataDirectoryService* orphaned_dir_service) { 212 GDataDirectoryService* orphaned_dir_service) {
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
230 GDataDirectory* dir = NULL; 214 GDataDirectory* dir = NULL;
231 // Added file. 215 // Added file.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // If the code above fails to parse a feed, any GDataEntry instance 306 // If the code above fails to parse a feed, any GDataEntry instance
323 // added to |file_by_url| is not managed by a GDataDirectory instance, 307 // added to |file_by_url| is not managed by a GDataDirectory instance,
324 // so we need to explicitly release them here. 308 // so we need to explicitly release them here.
325 STLDeleteValues(file_map); 309 STLDeleteValues(file_map);
326 } 310 }
327 311
328 return error; 312 return error;
329 } 313 }
330 314
331 } // namespace gdata 315 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698