
This reverts commite16ff9f100
. Reason for revert: Bot was still red after revert: https://ci.chromium.org/p/chromium/builders/ci/WebKit%20Linux%20Leak/15944 Original change's description: > Revert "Add StoragePartitionConfig class." > > This reverts commit225f6f4c82
. > > Reason for revert: I think this is causing failures in: > virtual/omt-worker-fetch/external/wpt/workers/modules/dedicated-worker-import.any.worker.html > http/tests/workers/worker-usecounter.html > virtual/omt-worker-fetch/http/tests/workers/worker-usecounter.html > and the "webkit_lint" step. > See example failure: https://ci.chromium.org/p/chromium/builders/ci/Win10%20Tests%20x64/47132 > > Original change's description: > > Add StoragePartitionConfig class. > > > > Introducing StoragePartitionConfig to make it easier for code to > > directly request the StoragePartition they need instead of having to > > go through the indirection of site URLs. Grouping the 3 attributes of > > a config into a class also makes several call sites simpler. This is > > being done as part of an effort to reduce the amount of code that > > depends on site URLs. > > > > - Created class for storing the storage partition > > <domain, name, in_memory> tuple. > > - Update GetStoragePartitionConfigForSite() and related code to use > > this new class. > > - Create BrowserContest::GetStoragePartition() method that takes > > StoragePartitionConfig as a parameter so future callers do not need > > to construct a site URL to get a storage partition. > > - Remove StoragePartitionImplMap::StoragePartitionConfig struct and > > convert StoragePartitionImplMap to use the new StoragePartitionConfig > > class. > > > > Bug: 1085275 > > Change-Id: I6679ee79ce88cf7cbfdfeb2686452d0cfcc1a9c3 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2253240 > > Commit-Queue: Aaron Colwell <acolwell@chromium.org> > > Reviewed-by: Aaron Colwell <acolwell@chromium.org> > > Reviewed-by: Alex Moshchuk <alexmos@chromium.org> > > Reviewed-by: James MacLean <wjmaclean@chromium.org> > > Reviewed-by: Karan Bhatia <karandeepb@chromium.org> > > Auto-Submit: Aaron Colwell <acolwell@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#781691} > > TBR=acolwell@chromium.org,alexmos@chromium.org,karandeepb@chromium.org,wjmaclean@chromium.org > > Change-Id: Iec47df87cb66a779d2d569e825c9b4ecccf1f2ef > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 1085275 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2263216 > Reviewed-by: Bret Sepulveda <bsep@chromium.org> > Commit-Queue: Bret Sepulveda <bsep@chromium.org> > Cr-Commit-Position: refs/heads/master@{#781798} TBR=acolwell@chromium.org,alexmos@chromium.org,bsep@chromium.org,karandeepb@chromium.org,wjmaclean@chromium.org # Not skipping CQ checks because this is a reland. Bug: 1085275 Change-Id: I6eaf4a96de9e08f93e450f708cf6eea5c33ec5b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264292 Reviewed-by: Bret Sepulveda <bsep@chromium.org> Commit-Queue: Bret Sepulveda <bsep@chromium.org> Cr-Commit-Position: refs/heads/master@{#781864}
104 lines
3.7 KiB
C++
104 lines
3.7 KiB
C++
// Copyright (c) 2012 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 CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_
|
|
#define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_set>
|
|
|
|
#include "base/callback_forward.h"
|
|
#include "base/gtest_prod_util.h"
|
|
#include "base/macros.h"
|
|
#include "base/supports_user_data.h"
|
|
#include "content/browser/storage_partition_impl.h"
|
|
#include "content/public/browser/browser_context.h"
|
|
#include "content/public/browser/storage_partition_config.h"
|
|
|
|
namespace base {
|
|
class FilePath;
|
|
class SequencedTaskRunner;
|
|
} // namespace base
|
|
|
|
namespace content {
|
|
|
|
class BrowserContext;
|
|
|
|
// A std::string to StoragePartition map for use with SupportsUserData APIs.
|
|
class CONTENT_EXPORT StoragePartitionImplMap
|
|
: public base::SupportsUserData::Data {
|
|
public:
|
|
explicit StoragePartitionImplMap(BrowserContext* browser_context);
|
|
|
|
~StoragePartitionImplMap() override;
|
|
|
|
// This map retains ownership of the returned StoragePartition objects.
|
|
StoragePartitionImpl* Get(const StoragePartitionConfig& partition_config,
|
|
bool can_create);
|
|
|
|
// Starts an asynchronous best-effort attempt to delete all on-disk storage
|
|
// related to |partition_domain|, avoiding any directories that are known to
|
|
// be in use.
|
|
//
|
|
// |on_gc_required| is called if the AsyncObliterate() call was unable to
|
|
// fully clean the on-disk storage requiring a call to GarbageCollect() on
|
|
// the next browser start.
|
|
void AsyncObliterate(const std::string& partition_domain,
|
|
base::OnceClosure on_gc_required);
|
|
|
|
// Examines the on-disk storage and removes any entires that are not listed
|
|
// in the |active_paths|, or in use by current entries in the storage
|
|
// partition.
|
|
//
|
|
// The |done| closure is executed on the calling thread when garbage
|
|
// collection is complete.
|
|
void GarbageCollect(
|
|
std::unique_ptr<std::unordered_set<base::FilePath>> active_paths,
|
|
base::OnceClosure done);
|
|
|
|
void ForEach(BrowserContext::StoragePartitionCallback callback);
|
|
|
|
size_t size() const { return partitions_.size(); }
|
|
|
|
private:
|
|
FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess);
|
|
FRIEND_TEST_ALL_PREFIXES(StoragePartitionImplMapTest, GarbageCollect);
|
|
|
|
typedef std::map<StoragePartitionConfig,
|
|
std::unique_ptr<StoragePartitionImpl>>
|
|
PartitionMap;
|
|
|
|
// Returns the relative path from the profile's base directory, to the
|
|
// directory that holds all the state for storage contexts in the given
|
|
// |partition_domain| and |partition_name|.
|
|
static base::FilePath GetStoragePartitionPath(
|
|
const std::string& partition_domain,
|
|
const std::string& partition_name);
|
|
|
|
// This must always be called *after* |partition| has been added to the
|
|
// partitions_.
|
|
//
|
|
// TODO(ajwong): Is there a way to make it so that Get()'s implementation
|
|
// doesn't need to be aware of this ordering? Revisit when refactoring
|
|
// ResourceContext and AppCache to respect storage partitions.
|
|
void PostCreateInitialization(StoragePartitionImpl* partition,
|
|
bool in_memory);
|
|
|
|
BrowserContext* browser_context_; // Not Owned.
|
|
scoped_refptr<base::SequencedTaskRunner> file_access_runner_;
|
|
PartitionMap partitions_;
|
|
|
|
// Set to true when the ResourceContext for the associated |browser_context_|
|
|
// is initialized. Can never return to false.
|
|
bool resource_context_initialized_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplMap);
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_
|