Add entry to histograms.xml for OverlyLargeOriginLength.
[chromium-blink-merge.git] / webkit / browser / fileapi / sandbox_prioritized_origin_database.h
blob5509d0f75be384c4d8c4d35cb2748aa494487830
1 // Copyright 2013 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.
5 #ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_
6 #define WEBKIT_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "webkit/browser/fileapi/sandbox_origin_database_interface.h"
14 namespace fileapi {
16 class ObfuscatedFileUtil;
17 class SandboxIsolatedOriginDatabase;
18 class SandboxOriginDatabase;
20 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase
21 : public SandboxOriginDatabaseInterface {
22 public:
23 explicit SandboxPrioritizedOriginDatabase(
24 const base::FilePath& file_system_directory);
25 virtual ~SandboxPrioritizedOriginDatabase();
27 // Sets |origin| as primary origin in this database (e.g. may
28 // allow faster access).
29 // Returns false if this database already has a primary origin
30 // which is different from |origin|.
31 bool InitializePrimaryOrigin(const std::string& origin);
32 std::string GetPrimaryOrigin();
34 // SandboxOriginDatabaseInterface overrides.
35 virtual bool HasOriginPath(const std::string& origin) OVERRIDE;
36 virtual bool GetPathForOrigin(const std::string& origin,
37 base::FilePath* directory) OVERRIDE;
38 virtual bool RemovePathForOrigin(const std::string& origin) OVERRIDE;
39 virtual bool ListAllOrigins(std::vector<OriginRecord>* origins) OVERRIDE;
40 virtual void DropDatabase() OVERRIDE;
42 const base::FilePath& primary_origin_file() const {
43 return primary_origin_file_;
46 private:
47 bool MaybeLoadPrimaryOrigin();
48 bool ResetPrimaryOrigin(const std::string& origin);
49 void MaybeMigrateDatabase(const std::string& origin);
50 void MaybeInitializeDatabases(bool create);
51 void MaybeInitializeNonPrimaryDatabase(bool create);
53 // For migration.
54 friend class ObfuscatedFileUtil;
55 SandboxOriginDatabase* GetSandboxOriginDatabase();
57 const base::FilePath file_system_directory_;
58 const base::FilePath primary_origin_file_;
59 scoped_ptr<SandboxOriginDatabase> origin_database_;
60 scoped_ptr<SandboxIsolatedOriginDatabase> primary_origin_database_;
62 DISALLOW_COPY_AND_ASSIGN(SandboxPrioritizedOriginDatabase);
65 } // namespace fileapi
67 #endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_PRIORITIZED_ORIGIN_DATABASE_H_