| Index: webkit/fileapi/path_obfuscator.h
|
| ===================================================================
|
| --- webkit/fileapi/path_obfuscator.h (revision 0)
|
| +++ webkit/fileapi/path_obfuscator.h (revision 0)
|
| @@ -0,0 +1,68 @@
|
| +// 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_PATH_OBFUSCATOR_H
|
| +#define WEBKIT_FILEAPI_PATH_OBFUSCATOR_H
|
| +
|
| +#include "base/file_path.h"
|
| +#include "base/platform_file.h"
|
| +#include "webkit/fileapi/obfuscated_name_map.h"
|
| +
|
| +using base::PlatformFileError;
|
| +
|
| +namespace fileapi {
|
| +
|
| +// This class is for use on the file thread only. TODO(ericu): Add CHECKs for
|
| +// this.
|
| +// The lifetime of the PathObfuscator must be limited such that any operation
|
| +// that could move the directory to which it refers happens outside that
|
| +// lifetime--otherwise you might be looking up keys in the wrong dictionary.
|
| +// Also, you shouldn't have more than one of these for the same directory at the
|
| +// same time, or they could get out of sync.
|
| +// You can reuse one of these for multiple operations as long as you manage it
|
| +// carefully: Rollback or Commit between each operation, and don't let it get
|
| +// out of sync.
|
| +class PathObfuscator {
|
| + public:
|
| + PathObfuscator(const FilePath& root_path);
|
| + ~PathObfuscator() {
|
| + Rollback();
|
| + }
|
| +
|
| + // As long as there's no salting on the hash, this can be static.
|
| + FilePath ObfuscatedPathFromClearPath(const FilePath& virtual_path);
|
| +
|
| + PlatformFileError ClearPathFromObfuscatedPath(
|
| + const FilePath& obfuscated_path,
|
| + FilePath* clear_path);
|
| +
|
| + PlatformFileError PrepareAdd(
|
| + const FilePath& clear_path,
|
| + const FilePath& obfuscated_path);
|
| +
|
| + PlatformFileError PrepareDelete(
|
| + const FilePath& clear_path,
|
| + const FilePath& obfuscated_path);
|
| +
|
| + PlatformFileError PrepareMove(
|
| + const FilePath& old_clear_path,
|
| + const FilePath& old_obfuscated_path,
|
| + const FilePath& new_clear_path,
|
| + const FilePath& new_obfuscated_path);
|
| +
|
| + PlatformFileError Commit();
|
| +
|
| + // Harmless if there no operation in progress.
|
| + void Rollback();
|
| +
|
| + private:
|
| + ObfuscatedNameMap from_map_;
|
| + ObfuscatedNameMap to_map_;
|
| + bool from_map_valid_, to_map_valid_;
|
| + FilePath root_path_;
|
| +};
|
| +
|
| +} // namespace fileapi
|
| +
|
| +#endif // WEBKIT_FILEAPI_PATH_OBFUSCATOR_H
|
|
|
| Property changes on: webkit\fileapi\path_obfuscator.h
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|