summaryrefslogtreecommitdiffstats
path: root/content/browser/storage_partition_impl.h
diff options
context:
space:
mode:
authornasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 08:31:53 +0000
committernasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 08:31:53 +0000
commit1bc2831891813f9cf9191c7d5deeccf246eff672 (patch)
treef4eb830fe3b63f5a891e802cbfa74e6616a62ce6 /content/browser/storage_partition_impl.h
parenteea2e67034a223c74ce0e8c0517f6066cc1ee143 (diff)
downloadchromium_src-1bc2831891813f9cf9191c7d5deeccf246eff672.zip
chromium_src-1bc2831891813f9cf9191c7d5deeccf246eff672.tar.gz
chromium_src-1bc2831891813f9cf9191c7d5deeccf246eff672.tar.bz2
Webview tag creation should be using storage partitions.
BUG=145500,149726 Review URL: https://chromiumcodereview.appspot.com/11234032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166639 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/storage_partition_impl.h')
-rw-r--r--content/browser/storage_partition_impl.h62
1 files changed, 56 insertions, 6 deletions
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h
index d3d6dba..9712837 100644
--- a/content/browser/storage_partition_impl.h
+++ b/content/browser/storage_partition_impl.h
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/dom_storage/dom_storage_context_impl.h"
@@ -19,12 +20,6 @@ class StoragePartitionImpl : public StoragePartition {
public:
virtual ~StoragePartitionImpl();
- // TODO(ajwong): Break the direct dependency on |context|. We only
- // need 3 pieces of info from it.
- static StoragePartitionImpl* Create(BrowserContext* context,
- const std::string& partition_id,
- const FilePath& profile_path);
-
// StoragePartition interface.
virtual FilePath GetPath() OVERRIDE;
virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
@@ -37,8 +32,63 @@ class StoragePartitionImpl : public StoragePartition {
virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
private:
+ FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess);
friend class StoragePartitionImplMap;
+ // Each StoragePartition is uniquely identified by which partition domain
+ // it belongs to (such as an app or the browser itself), the user supplied
+ // partition name and the bit indicating whether it should be persisted on
+ // disk or not. This structure contains those elements and is used as
+ // uniqueness key to lookup StoragePartition objects in the global map.
+ //
+ // TODO(nasko): It is equivalent, though not identical to the same structure
+ // that lives in chrome profiles. The difference is that this one has
+ // partition_domain and partition_name separate, while the latter one has
+ // the path produced by combining the two pieces together.
+ // The fix for http://crbug.com/159193 will remove the chrome version.
+ struct StoragePartitionConfig {
+ const std::string partition_domain;
+ const std::string partition_name;
+ const bool in_memory;
+
+ StoragePartitionConfig(const std::string& domain,
+ const std::string& partition,
+ const bool& in_memory_only)
+ : partition_domain(domain),
+ partition_name(partition),
+ in_memory(in_memory_only) {}
+ };
+
+ // Functor for operator <.
+ struct StoragePartitionConfigLess {
+ bool operator()(const StoragePartitionConfig& lhs,
+ const StoragePartitionConfig& rhs) const {
+ if (lhs.partition_domain != rhs.partition_domain)
+ return lhs.partition_domain < rhs.partition_domain;
+ else if (lhs.partition_name != rhs.partition_name)
+ return lhs.partition_name < rhs.partition_name;
+ else if (lhs.in_memory != rhs.in_memory)
+ return lhs.in_memory < rhs.in_memory;
+ else
+ return false;
+ }
+ };
+
+ // TODO(ajwong): Break the direct dependency on |context|. We only
+ // need 3 pieces of info from it.
+ static StoragePartitionImpl* Create(
+ BrowserContext* context,
+ const StoragePartitionConfig& partition_id,
+ const FilePath& profile_path);
+
+ // Returns the relative path from the profile's base directory, to the
+ // directory that holds all the state for storage contexts in
+ // |partition_config|. If any of the strings in |partition_config| contain
+ // embedded nuls, the values will be truncated and only the portion prior to
+ // the nul will be used.
+ static FilePath GetStoragePartitionPath(
+ const StoragePartitionConfig& partition_config);
+
StoragePartitionImpl(
const FilePath& partition_path,
quota::QuotaManager* quota_manager,