| 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_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <set> | 10 #include <set> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/browser/appcache/appcache_response.h" | 15 #include "content/browser/appcache/appcache_response.h" |
| 14 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 15 #include "net/disk_cache/disk_cache.h" | 17 #include "net/disk_cache/disk_cache.h" |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 const net::CompletionCallback& callback); | 39 const net::CompletionCallback& callback); |
| 38 | 40 |
| 39 // Initializes the object to use memory only storage. | 41 // Initializes the object to use memory only storage. |
| 40 // This is used for Chrome's incognito browsing. | 42 // This is used for Chrome's incognito browsing. |
| 41 int InitWithMemBackend(int disk_cache_size, | 43 int InitWithMemBackend(int disk_cache_size, |
| 42 const net::CompletionCallback& callback); | 44 const net::CompletionCallback& callback); |
| 43 | 45 |
| 44 void Disable(); | 46 void Disable(); |
| 45 bool is_disabled() const { return is_disabled_; } | 47 bool is_disabled() const { return is_disabled_; } |
| 46 | 48 |
| 47 int CreateEntry(int64 key, | 49 int CreateEntry(int64_t key, |
| 48 Entry** entry, | 50 Entry** entry, |
| 49 const net::CompletionCallback& callback) override; | 51 const net::CompletionCallback& callback) override; |
| 50 int OpenEntry(int64 key, | 52 int OpenEntry(int64_t key, |
| 51 Entry** entry, | 53 Entry** entry, |
| 52 const net::CompletionCallback& callback) override; | 54 const net::CompletionCallback& callback) override; |
| 53 int DoomEntry(int64 key, const net::CompletionCallback& callback) override; | 55 int DoomEntry(int64_t key, const net::CompletionCallback& callback) override; |
| 54 | 56 |
| 55 void set_is_waiting_to_initialize(bool is_waiting_to_initialize) { | 57 void set_is_waiting_to_initialize(bool is_waiting_to_initialize) { |
| 56 is_waiting_to_initialize_ = is_waiting_to_initialize; | 58 is_waiting_to_initialize_ = is_waiting_to_initialize; |
| 57 } | 59 } |
| 58 | 60 |
| 59 protected: | 61 protected: |
| 60 explicit AppCacheDiskCache(bool use_simple_cache); | 62 explicit AppCacheDiskCache(bool use_simple_cache); |
| 61 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } | 63 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 class CreateBackendCallbackShim; | 66 class CreateBackendCallbackShim; |
| 65 class EntryImpl; | 67 class EntryImpl; |
| 66 | 68 |
| 67 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called | 69 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called |
| 68 // immediately after construction, without waiting for the | 70 // immediately after construction, without waiting for the |
| 69 // underlying disk_cache::Backend to be fully constructed. Early | 71 // underlying disk_cache::Backend to be fully constructed. Early |
| 70 // calls are queued up and serviced once the disk_cache::Backend is | 72 // calls are queued up and serviced once the disk_cache::Backend is |
| 71 // really ready to go. | 73 // really ready to go. |
| 72 enum PendingCallType { | 74 enum PendingCallType { |
| 73 CREATE, | 75 CREATE, |
| 74 OPEN, | 76 OPEN, |
| 75 DOOM | 77 DOOM |
| 76 }; | 78 }; |
| 77 struct PendingCall { | 79 struct PendingCall { |
| 78 PendingCallType call_type; | 80 PendingCallType call_type; |
| 79 int64 key; | 81 int64_t key; |
| 80 Entry** entry; | 82 Entry** entry; |
| 81 net::CompletionCallback callback; | 83 net::CompletionCallback callback; |
| 82 | 84 |
| 83 PendingCall(); | 85 PendingCall(); |
| 84 | 86 |
| 85 PendingCall(PendingCallType call_type, int64 key, | 87 PendingCall(PendingCallType call_type, |
| 86 Entry** entry, const net::CompletionCallback& callback); | 88 int64_t key, |
| 89 Entry** entry, |
| 90 const net::CompletionCallback& callback); |
| 87 | 91 |
| 88 ~PendingCall(); | 92 ~PendingCall(); |
| 89 }; | 93 }; |
| 90 typedef std::vector<PendingCall> PendingCalls; | 94 typedef std::vector<PendingCall> PendingCalls; |
| 91 | 95 |
| 92 class ActiveCall; | 96 class ActiveCall; |
| 93 typedef std::set<ActiveCall*> ActiveCalls; | 97 typedef std::set<ActiveCall*> ActiveCalls; |
| 94 typedef std::set<EntryImpl*> OpenEntries; | 98 typedef std::set<EntryImpl*> OpenEntries; |
| 95 | 99 |
| 96 bool is_initializing_or_waiting_to_initialize() const { | 100 bool is_initializing_or_waiting_to_initialize() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 PendingCalls pending_calls_; | 119 PendingCalls pending_calls_; |
| 116 OpenEntries open_entries_; | 120 OpenEntries open_entries_; |
| 117 scoped_ptr<disk_cache::Backend> disk_cache_; | 121 scoped_ptr<disk_cache::Backend> disk_cache_; |
| 118 | 122 |
| 119 base::WeakPtrFactory<AppCacheDiskCache> weak_factory_; | 123 base::WeakPtrFactory<AppCacheDiskCache> weak_factory_; |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 } // namespace content | 126 } // namespace content |
| 123 | 127 |
| 124 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ | 128 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ |
| OLD | NEW |