Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: services/url_response_disk_cache/url_response_disk_cache_impl.h

Issue 1276073004: Offline By Default (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add missing explicits. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/url_response_disk_cache/url_response_disk_cache_impl.h
diff --git a/services/url_response_disk_cache/url_response_disk_cache_impl.h b/services/url_response_disk_cache/url_response_disk_cache_impl.h
index fc70766623474140535f5cee0e664a16ab188107..95695e73497f40d649660aa0a5a1ebd14abd0769 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_impl.h
+++ b/services/url_response_disk_cache/url_response_disk_cache_impl.h
@@ -7,55 +7,63 @@
#include "base/files/file_path.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/task_runner.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/url_response_disk_cache/public/interfaces/url_response_disk_cache.mojom.h"
+#include "services/url_response_disk_cache/url_response_disk_cache_db.h"
namespace mojo {
class URLResponseDiskCacheImpl : public URLResponseDiskCache {
public:
- using FilePathPairCallback =
+ using ResponseFileAndCacheDirCallback =
base::Callback<void(const base::FilePath&, const base::FilePath&)>;
- // Cleares the cached content. The actual deletion will be performed using the
- // given task runner, but cache appears as cleared immediately after the
- // function returns.
- static void ClearCache(base::TaskRunner* task_runner);
+ // Creates the disk cache database. If |force_clean| is true, or the database
+ // is outdated, it will clear the cached content. The actual deletion will be
+ // performed using the given task runner, but cache appears as cleared
+ // immediately after the function returns.
+ static scoped_refptr<URLResponseDiskCacheDB> CreateDB(
+ scoped_refptr<base::TaskRunner> task_runner,
+ bool force_clean);
- URLResponseDiskCacheImpl(base::TaskRunner* task_runner,
+ URLResponseDiskCacheImpl(scoped_refptr<base::TaskRunner> task_runner,
+ scoped_refptr<URLResponseDiskCacheDB> db,
const std::string& remote_application_url,
InterfaceRequest<URLResponseDiskCache> request);
~URLResponseDiskCacheImpl() override;
private:
// URLResponseDiskCache
- void GetFile(mojo::URLResponsePtr response,
- const GetFileCallback& callback) override;
- void GetExtractedContent(
- mojo::URLResponsePtr response,
- const GetExtractedContentCallback& callback) override;
+ void Get(const String& url, const GetCallback& callback) override;
+ void Update(URLResponsePtr response) override;
+ void UpdateAndGet(URLResponsePtr response,
+ const UpdateAndGetCallback& callback) override;
+ void UpdateAndGetExtracted(
+ URLResponsePtr response,
+ const UpdateAndGetExtractedCallback& callback) override;
- // As |GetFile|, but uses FilePath instead of mojo arrays.
- void GetFileInternal(mojo::URLResponsePtr response,
- const FilePathPairCallback& callback);
+ // Internal implementation of |UpdateAndGet| using a pair of base::FilePath to
+ // represent the paths the the response body and to the per-response client
+ // cache directory.
+ void UpdateAndGetInternal(URLResponsePtr response,
+ const ResponseFileAndCacheDirCallback& callback);
- // Internal implementation of |GetExtractedContent|. The parameters are:
+ // Internal implementation of |UpdateAndGetExtracted|. The parameters are:
// |callback|: The callback to return values to the caller. It uses FilePath
// instead of mojo arrays.
- // |base_dir|: The base directory for caching data associated to the response.
- // |extracted_dir|: The directory where the file content must be extracted. It
- // will be returned to the consumer.
- // |content|: The content of the body of the response.
- // |cache_dir|: The directory the user can user to cache its own content.
- void GetExtractedContentInternal(const FilePathPairCallback& callback,
- const base::FilePath& base_dir,
- const base::FilePath& extracted_dir,
- const base::FilePath& content,
- const base::FilePath& cache_dir);
+ // |response_body_path|: The path to the content of the body of the response.
+ // |consumer_cache_directory|: The directory the user can user to cache its
+ // own content.
+ void UpdateAndGetExtractedInternal(
+ const ResponseFileAndCacheDirCallback& callback,
+ const base::FilePath& response_body_path,
+ const base::FilePath& consumer_cache_directory);
- base::TaskRunner* task_runner_;
- base::FilePath base_directory_;
+ scoped_refptr<base::TaskRunner> task_runner_;
+ std::string request_origin_;
+ scoped_refptr<URLResponseDiskCacheDB> db_;
StrongBinding<URLResponseDiskCache> binding_;
DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheImpl);

Powered by Google App Engine
This is Rietveld 408576698