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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_backend.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes 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
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/extensions/api/storage/settings_backend.h" 5 #include "chrome/browser/extensions/api/storage/settings_backend.h"
6 6
7 #include "base/file_util.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h" 9 #include "chrome/browser/extensions/api/storage/settings_sync_processor.h"
10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 10 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
11 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" 11 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "sync/api/sync_error_factory.h" 13 #include "sync/api/sync_error_factory.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 16
17 namespace extensions { 17 namespace extensions {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 std::set<std::string> result; 98 std::set<std::string> result;
99 99
100 // Storage areas can be in-memory as well as on disk. |storage_objs_| will 100 // Storage areas can be in-memory as well as on disk. |storage_objs_| will
101 // contain all that are in-memory. 101 // contain all that are in-memory.
102 for (StorageObjMap::iterator it = storage_objs_.begin(); 102 for (StorageObjMap::iterator it = storage_objs_.begin();
103 it != storage_objs_.end(); ++it) { 103 it != storage_objs_.end(); ++it) {
104 result.insert(it->first); 104 result.insert(it->first);
105 } 105 }
106 106
107 // Leveldb databases are directories inside base_path_. 107 // Leveldb databases are directories inside base_path_.
108 file_util::FileEnumerator::FindInfo find_info; 108 base::FileEnumerator extension_dirs(
109 file_util::FileEnumerator extension_dirs( 109 base_path_, false, base::FileEnumerator::DIRECTORIES);
110 base_path_, false, file_util::FileEnumerator::DIRECTORIES);
111 while (!extension_dirs.Next().empty()) { 110 while (!extension_dirs.Next().empty()) {
112 extension_dirs.GetFindInfo(&find_info); 111 base::FilePath extension_dir = extension_dirs.GetInfo().GetName();
113 base::FilePath extension_dir(
114 file_util::FileEnumerator::GetFilename(find_info));
115 DCHECK(!extension_dir.IsAbsolute()); 112 DCHECK(!extension_dir.IsAbsolute());
116 // Extension IDs are created as std::strings so they *should* be ASCII. 113 // Extension IDs are created as std::strings so they *should* be ASCII.
117 std::string maybe_as_ascii(extension_dir.MaybeAsASCII()); 114 std::string maybe_as_ascii(extension_dir.MaybeAsASCII());
118 if (!maybe_as_ascii.empty()) { 115 if (!maybe_as_ascii.empty()) {
119 result.insert(maybe_as_ascii); 116 result.insert(maybe_as_ascii);
120 } 117 }
121 } 118 }
122 119
123 return result; 120 return result;
124 } 121 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor( 274 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor(
278 const std::string& extension_id) const { 275 const std::string& extension_id) const {
279 CHECK(sync_processor_.get()); 276 CHECK(sync_processor_.get());
280 return scoped_ptr<SettingsSyncProcessor>( 277 return scoped_ptr<SettingsSyncProcessor>(
281 new SettingsSyncProcessor(extension_id, 278 new SettingsSyncProcessor(extension_id,
282 sync_type_, 279 sync_type_,
283 sync_processor_.get())); 280 sync_processor_.get()));
284 } 281 }
285 282
286 } // namespace extensions 283 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698