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

Unified Diff: webkit/fileapi/obfuscated_name_map.h

Issue 6286038: Add initial code to do filename munging in the FileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/obfuscated_name_map.h
===================================================================
--- webkit/fileapi/obfuscated_name_map.h (revision 0)
+++ webkit/fileapi/obfuscated_name_map.h (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_OBFUSCATED_NAME_MAP_H_
+#define WEBKIT_FILEAPI_OBFUSCATED_NAME_MAP_H_
+
+#include "base/file_path.h"
+#include "base/hash_tables.h"
+#include "base/platform_file.h"
+
+namespace obfuscated_file_util {
+
+using base::PlatformFile;
+using base::PlatformFileError;
+
+typedef FilePath::StringType StringType;
+
+// This can be reused, but call Init between uses if you want to switch
+// directory. You must either RollBack or Commit each change individually. If
+// you get an error, call either Init or RollBack before trying to reuse the
+// object.
michaeln 2011/02/11 00:03:34 class comments about what this class does might be
ericu 2011/02/11 01:57:47 Hmm...I thought it best to put "how to reuse this
+class ObfuscatedNameMap {
+ public:
+ ObfuscatedNameMap();
+ ~ObfuscatedNameMap() {
+ RollBack();
+ }
+
+ void Init(const FilePath& directory);
+
+ PlatformFileError ClearNameFromObfuscatedName(
+ StringType obfuscated_name,
+ StringType* clear_name);
+
+ static StringType ObfuscatedNameFromClearName(StringType clear_name);
+
+ PlatformFileError PrepareAdd(
+ const StringType& clear_name, const StringType& obfuscated_name);
+
+ PlatformFileError PrepareDelete(
+ const StringType& clear_name, const StringType& obfuscated_name);
+
+ PlatformFileError PrepareMove(
+ const StringType& old_clear_name,
+ const StringType& old_obfuscated_name,
+ const StringType& new_clear_name,
+ const StringType& new_obfuscated_name);
+
+ PlatformFileError Commit();
+
+ // Harmless if there no operation in progress.
+ void RollBack();
michaeln 2011/02/11 00:03:34 There's precedence in the project for 'Rollback' w
ericu 2011/02/11 01:57:47 OK, will change.
+
+ private:
+ typedef base::hash_map<StringType, StringType> MapType;
+
+ static size_t hash(const FilePath& f);
+ FilePath GetDictionaryLocation();
+ FilePath GetDictionaryNextLocation();
+ PlatformFileError LoadFromFile();
+ void LoadMapFromString(MapType* map, const StringType& serialized);
+ StringType ConvertMapToString(const MapType& map);
+ PlatformFileError InitDictNext();
+ PlatformFileError RecoverIfNeeded();
+ PlatformFileError WriteToNextFile();
+
+ static const StringType DICTIONARY_NAME;
+ static const StringType DICTIONARY_NEXT_NAME;
+ static const StringType SEPARATOR;
+ static const StringType TERMINATOR;
+
+ MapType map_;
+ MapType map_next_;
+ bool map_valid_;
+ bool map_next_valid_; // == operation in progress
+ FilePath directory_;
+};
+
+} // namespace obfuscated_file_util
+
+#endif // WEBKIT_FILEAPI_OBFUSCATED_NAME_MAP_H_
Property changes on: webkit\fileapi\obfuscated_name_map.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698