| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ | 5 #ifndef SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ |
| 6 #define SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ | 6 #define SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/services/url_response_disk_cache/public/interfaces/url_response_d
isk_cache.mojom.h" | 13 #include "mojo/services/url_response_disk_cache/public/interfaces/url_response_d
isk_cache.mojom.h" |
| 14 #include "services/url_response_disk_cache/url_response_disk_cache_db.h" | 14 #include "services/url_response_disk_cache/url_response_disk_cache_db.h" |
| 15 #include "services/url_response_disk_cache/url_response_disk_cache_delegate.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 | 18 |
| 18 class URLResponseDiskCacheImpl : public URLResponseDiskCache { | 19 class URLResponseDiskCacheImpl : public URLResponseDiskCache { |
| 19 public: | 20 public: |
| 20 using ResponseFileAndCacheDirCallback = | 21 using ResponseFileAndCacheDirCallback = |
| 21 base::Callback<void(const base::FilePath&, const base::FilePath&)>; | 22 base::Callback<void(const base::FilePath&, const base::FilePath&)>; |
| 22 | 23 |
| 23 // Creates the disk cache database. If |force_clean| is true, or the database | 24 // Creates the disk cache database. If |force_clean| is true, or the database |
| 24 // is outdated, it will clear the cached content. The actual deletion will be | 25 // is outdated, it will clear the cached content. The actual deletion will be |
| 25 // performed using the given task runner, but cache appears as cleared | 26 // performed using the given task runner, but cache appears as cleared |
| 26 // immediately after the function returns. | 27 // immediately after the function returns. |
| 27 static scoped_refptr<URLResponseDiskCacheDB> CreateDB( | 28 static scoped_refptr<URLResponseDiskCacheDB> CreateDB( |
| 28 scoped_refptr<base::TaskRunner> task_runner, | 29 scoped_refptr<base::TaskRunner> task_runner, |
| 29 bool force_clean); | 30 bool force_clean); |
| 30 | 31 |
| 31 URLResponseDiskCacheImpl(scoped_refptr<base::TaskRunner> task_runner, | 32 URLResponseDiskCacheImpl(scoped_refptr<base::TaskRunner> task_runner, |
| 33 URLResponseDiskCacheDelegate* delegate, |
| 32 scoped_refptr<URLResponseDiskCacheDB> db, | 34 scoped_refptr<URLResponseDiskCacheDB> db, |
| 33 const std::string& remote_application_url, | 35 const std::string& remote_application_url, |
| 34 InterfaceRequest<URLResponseDiskCache> request); | 36 InterfaceRequest<URLResponseDiskCache> request); |
| 35 ~URLResponseDiskCacheImpl() override; | 37 ~URLResponseDiskCacheImpl() override; |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 // URLResponseDiskCache | 40 // URLResponseDiskCache |
| 39 void Get(const String& url, const GetCallback& callback) override; | 41 void Get(const String& url, const GetCallback& callback) override; |
| 40 void Update(URLResponsePtr response) override; | 42 void Update(URLResponsePtr response) override; |
| 41 void Validate(const String& url) override; | 43 void Validate(const String& url) override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 // |response_body_path|: The path to the content of the body of the response. | 59 // |response_body_path|: The path to the content of the body of the response. |
| 58 // |consumer_cache_directory|: The directory the user can user to cache its | 60 // |consumer_cache_directory|: The directory the user can user to cache its |
| 59 // own content. | 61 // own content. |
| 60 void UpdateAndGetExtractedInternal( | 62 void UpdateAndGetExtractedInternal( |
| 61 const ResponseFileAndCacheDirCallback& callback, | 63 const ResponseFileAndCacheDirCallback& callback, |
| 62 const base::FilePath& response_body_path, | 64 const base::FilePath& response_body_path, |
| 63 const base::FilePath& consumer_cache_directory); | 65 const base::FilePath& consumer_cache_directory); |
| 64 | 66 |
| 65 scoped_refptr<base::TaskRunner> task_runner_; | 67 scoped_refptr<base::TaskRunner> task_runner_; |
| 66 std::string request_origin_; | 68 std::string request_origin_; |
| 69 URLResponseDiskCacheDelegate* delegate_; |
| 67 scoped_refptr<URLResponseDiskCacheDB> db_; | 70 scoped_refptr<URLResponseDiskCacheDB> db_; |
| 68 StrongBinding<URLResponseDiskCache> binding_; | 71 StrongBinding<URLResponseDiskCache> binding_; |
| 69 | 72 |
| 70 DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheImpl); | 73 DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheImpl); |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 } // namespace mojo | 76 } // namespace mojo |
| 74 | 77 |
| 75 #endif // SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ | 78 #endif // SERVICES_URL_RESPONSE_DISK_CACHE_URL_RESPONSE_DISK_CACHE_IMPL_H_ |
| OLD | NEW |