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

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

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 std::set<std::string> result; 108 std::set<std::string> result;
109 109
110 // Storage areas can be in-memory as well as on disk. |storage_objs_| will 110 // Storage areas can be in-memory as well as on disk. |storage_objs_| will
111 // contain all that are in-memory. 111 // contain all that are in-memory.
112 for (StorageObjMap::iterator it = storage_objs_.begin(); 112 for (StorageObjMap::iterator it = storage_objs_.begin();
113 it != storage_objs_.end(); ++it) { 113 it != storage_objs_.end(); ++it) {
114 result.insert(it->first); 114 result.insert(it->first);
115 } 115 }
116 116
117 // Leveldb databases are directories inside base_path_. 117 // Leveldb databases are directories inside base_path_.
118 file_util::FileEnumerator::FindInfo find_info; 118 base::FileEnumerator extension_dirs(
119 file_util::FileEnumerator extension_dirs( 119 base_path_, false, base::FileEnumerator::DIRECTORIES);
120 base_path_, false, file_util::FileEnumerator::DIRECTORIES);
121 while (!extension_dirs.Next().empty()) { 120 while (!extension_dirs.Next().empty()) {
122 extension_dirs.GetFindInfo(&find_info); 121 base::FilePath extension_dir = extension_dirs.GetInfo().GetName();
123 base::FilePath extension_dir(
124 file_util::FileEnumerator::GetFilename(find_info));
125 DCHECK(!extension_dir.IsAbsolute()); 122 DCHECK(!extension_dir.IsAbsolute());
126 // Extension IDs are created as std::strings so they *should* be ASCII. 123 // Extension IDs are created as std::strings so they *should* be ASCII.
127 std::string maybe_as_ascii(extension_dir.MaybeAsASCII()); 124 std::string maybe_as_ascii(extension_dir.MaybeAsASCII());
128 if (!maybe_as_ascii.empty()) { 125 if (!maybe_as_ascii.empty()) {
129 result.insert(maybe_as_ascii); 126 result.insert(maybe_as_ascii);
130 } 127 }
131 } 128 }
132 129
133 return result; 130 return result;
134 } 131 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor( 280 scoped_ptr<SettingsSyncProcessor> SettingsBackend::CreateSettingsSyncProcessor(
284 const std::string& extension_id) const { 281 const std::string& extension_id) const {
285 CHECK(sync_processor_.get()); 282 CHECK(sync_processor_.get());
286 return scoped_ptr<SettingsSyncProcessor>( 283 return scoped_ptr<SettingsSyncProcessor>(
287 new SettingsSyncProcessor(extension_id, 284 new SettingsSyncProcessor(extension_id,
288 sync_type_, 285 sync_type_,
289 sync_processor_.get())); 286 sync_processor_.get()));
290 } 287 }
291 288
292 } // namespace extensions 289 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698