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

Side by Side Diff: webkit/fileapi/path_obfuscator.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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_FILEAPI_PATH_OBFUSCATOR_H
6 #define WEBKIT_FILEAPI_PATH_OBFUSCATOR_H
7
8 #include "base/file_path.h"
9 #include "base/platform_file.h"
10 #include "webkit/fileapi/obfuscated_name_map.h"
11
12 using base::PlatformFileError;
13
14 namespace obfuscated_file_util {
15
16 // This class is for use on the file thread only. TODO(ericu): Add CHECKs for
17 // this.
18 // The lifetime of the PathObfuscator must be limited such that any operation
19 // that could move the directory to which it refers happens outside that
20 // lifetime--otherwise you might be looking up keys in the wrong dictionary.
21 // Also, you shouldn't have more than one of these for the same directory at the
22 // same time, or they could get out of sync.
23 // You can reuse one of these for multiple operations as long as you manage it
24 // carefully: RollBack or Commit between each operation, and don't let it get
25 // out of sync.
26 class PathObfuscator {
27 public:
28 PathObfuscator(const FilePath& root_path);
29 ~PathObfuscator() {
30 RollBack();
31 }
32
33 // As long as there's no salting on the hash, this can be static.
34 FilePath ObfuscatedPathFromClearPath(const FilePath& virtual_path);
35
36 PlatformFileError ClearPathFromObfuscatedPath(
37 const FilePath& obfuscated_path,
38 FilePath* clear_path);
39
40 PlatformFileError PrepareAdd(
41 const FilePath& clear_path,
42 const FilePath& obfuscated_path);
43
44 PlatformFileError PrepareDelete(
45 const FilePath& clear_path,
46 const FilePath& obfuscated_path);
47
48 PlatformFileError PrepareMove(
49 const FilePath& old_clear_path,
50 const FilePath& old_obfuscated_path,
51 const FilePath& new_clear_path,
52 const FilePath& new_obfuscated_path);
53
54 PlatformFileError Commit();
55
56 // Harmless if there no operation in progress.
57 void RollBack();
58
59 private:
60 ObfuscatedNameMap from_map_, to_map_;
michaeln 2011/02/11 00:03:34 we usually declare one data member per line, but i
ericu 2011/02/11 01:57:47 An easy fix, anyway.
61 bool from_map_valid_, to_map_valid_;
62 FilePath root_path_;
63 };
64
65 } // namespace obfuscated_file_util
66
67 #endif // WEBKIT_FILEAPI_PATH_OBFUSCATOR_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698