| OLD | NEW |
| 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 #ifndef CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/indexed_db_info.h" | 16 #include "content/public/browser/indexed_db_info.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class SequencedTaskRunner; | 19 class SingleThreadTaskRunner; |
| 20 } |
| 21 |
| 22 namespace storage { |
| 23 class QuotaManagerProxy; |
| 24 } |
| 25 |
| 26 namespace url { |
| 27 class Origin; |
| 20 } | 28 } |
| 21 | 29 |
| 22 namespace content { | 30 namespace content { |
| 23 | 31 |
| 24 // Represents the per-BrowserContext IndexedDB data. | 32 // Represents the per-BrowserContext IndexedDB data. |
| 25 // Call these methods only via the exposed TaskRunner. | 33 // Call these methods only via the exposed TaskRunner. |
| 26 class IndexedDBContext : public base::RefCountedThreadSafe<IndexedDBContext> { | 34 class IndexedDBContext : public base::RefCountedThreadSafe<IndexedDBContext> { |
| 27 public: | 35 public: |
| 28 // Only call the below methods by posting to this TaskRunner. | 36 // Only call the below methods by posting to this TaskRunner. |
| 29 virtual base::SequencedTaskRunner* TaskRunner() const = 0; | 37 virtual base::SingleThreadTaskRunner* TaskRunner() const = 0; |
| 30 | 38 |
| 31 // Methods used in response to QuotaManager requests. | 39 // Methods used in response to QuotaManager requests. |
| 32 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() = 0; | 40 virtual std::vector<IndexedDBInfo> GetAllOriginsInfo() = 0; |
| 33 virtual int64_t GetOriginDiskUsage(const GURL& origin_url) = 0; | 41 virtual int64_t GetOriginDiskUsage(const GURL& origin_url) = 0; |
| 34 | 42 |
| 35 // Deletes all indexed db files for the given origin. | 43 // Deletes all indexed db files for the given origin. |
| 36 virtual void DeleteForOrigin(const GURL& origin_url) = 0; | 44 virtual void DeleteForOrigin(const GURL& origin_url) = 0; |
| 37 | 45 |
| 38 // Copies the indexed db files from this context to another. The | 46 // Copies the indexed db files from this context to another. The |
| 39 // indexed db directory in the destination context needs to be empty. | 47 // indexed db directory in the destination context needs to be empty. |
| 40 virtual void CopyOriginData(const GURL& origin_url, | 48 virtual void CopyOriginData(const GURL& origin_url, |
| 41 IndexedDBContext* dest_context) = 0; | 49 IndexedDBContext* dest_context) = 0; |
| 42 | 50 |
| 43 // Get the file name of the local storage file for the given origin. | 51 // Get the file name of the local storage file for the given origin. |
| 44 virtual base::FilePath GetFilePathForTesting( | 52 virtual base::FilePath GetFilePathForTesting( |
| 45 const GURL& origin_url) const = 0; | 53 const GURL& origin_url) const = 0; |
| 46 | 54 |
| 47 // Set the task runner for tests if browser main loop is not initialized. | 55 // Set the task runner for tests if browser main loop is not initialized. |
| 48 virtual void SetTaskRunnerForTesting( | 56 virtual void SetTaskRunnerForTesting( |
| 49 base::SequencedTaskRunner* task_runner) = 0; | 57 base::SingleThreadTaskRunner* task_runner) = 0; |
| 58 |
| 59 // Will be null in unit tests. |
| 60 virtual storage::QuotaManagerProxy* quota_manager_proxy() const = 0; |
| 61 |
| 62 // A transaction on the given origin was just completed. |
| 63 virtual void TransactionComplete(const url::Origin& origin) = 0; |
| 50 | 64 |
| 51 protected: | 65 protected: |
| 52 friend class base::RefCountedThreadSafe<IndexedDBContext>; | 66 friend class base::RefCountedThreadSafe<IndexedDBContext>; |
| 53 virtual ~IndexedDBContext() {} | 67 virtual ~IndexedDBContext() {} |
| 54 }; | 68 }; |
| 55 | 69 |
| 56 } // namespace content | 70 } // namespace content |
| 57 | 71 |
| 58 #endif // CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ | 72 #endif // CONTENT_PUBLIC_BROWSER_INDEXED_DB_CONTEXT_H_ |
| OLD | NEW |