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

Side by Side Diff: content/browser/appcache/appcache_disk_cache.h

Issue 1152543002: ServiceWorker: Migrate the script cache backend from BlockFile to Simple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 bool is_disabled() const { return is_disabled_; } 45 bool is_disabled() const { return is_disabled_; }
46 46
47 int CreateEntry(int64 key, 47 int CreateEntry(int64 key,
48 Entry** entry, 48 Entry** entry,
49 const net::CompletionCallback& callback) override; 49 const net::CompletionCallback& callback) override;
50 int OpenEntry(int64 key, 50 int OpenEntry(int64 key,
51 Entry** entry, 51 Entry** entry,
52 const net::CompletionCallback& callback) override; 52 const net::CompletionCallback& callback) override;
53 int DoomEntry(int64 key, const net::CompletionCallback& callback) override; 53 int DoomEntry(int64 key, const net::CompletionCallback& callback) override;
54 54
55 void set_is_waiting_to_initialize(bool is_waiting_to_initialize) {
56 is_waiting_to_initialize_ = is_waiting_to_initialize;
57 }
58
55 protected: 59 protected:
56 explicit AppCacheDiskCache(bool use_simple_cache); 60 explicit AppCacheDiskCache(bool use_simple_cache);
57 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } 61 disk_cache::Backend* disk_cache() { return disk_cache_.get(); }
58 62
59 private: 63 private:
60 class CreateBackendCallbackShim; 64 class CreateBackendCallbackShim;
61 class EntryImpl; 65 class EntryImpl;
62 66
63 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called 67 // PendingCalls allow CreateEntry, OpenEntry, and DoomEntry to be called
64 // immediately after construction, without waiting for the 68 // immediately after construction, without waiting for the
(...skipping 17 matching lines...) Expand all
82 Entry** entry, const net::CompletionCallback& callback); 86 Entry** entry, const net::CompletionCallback& callback);
83 87
84 ~PendingCall(); 88 ~PendingCall();
85 }; 89 };
86 typedef std::vector<PendingCall> PendingCalls; 90 typedef std::vector<PendingCall> PendingCalls;
87 91
88 class ActiveCall; 92 class ActiveCall;
89 typedef std::set<ActiveCall*> ActiveCalls; 93 typedef std::set<ActiveCall*> ActiveCalls;
90 typedef std::set<EntryImpl*> OpenEntries; 94 typedef std::set<EntryImpl*> OpenEntries;
91 95
92 bool is_initializing() const { 96 bool is_initializing_or_waiting_to_initialize() const {
93 return create_backend_callback_.get() != NULL; 97 return create_backend_callback_.get() != NULL || is_waiting_to_initialize_;
94 } 98 }
99
95 int Init(net::CacheType cache_type, 100 int Init(net::CacheType cache_type,
96 const base::FilePath& directory, 101 const base::FilePath& directory,
97 int cache_size, 102 int cache_size,
98 bool force, 103 bool force,
99 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, 104 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread,
100 const net::CompletionCallback& callback); 105 const net::CompletionCallback& callback);
101 void OnCreateBackendComplete(int rv); 106 void OnCreateBackendComplete(int rv);
102 void AddOpenEntry(EntryImpl* entry) { open_entries_.insert(entry); } 107 void AddOpenEntry(EntryImpl* entry) { open_entries_.insert(entry); }
103 void RemoveOpenEntry(EntryImpl* entry) { open_entries_.erase(entry); } 108 void RemoveOpenEntry(EntryImpl* entry) { open_entries_.erase(entry); }
104 109
105 bool use_simple_cache_; 110 bool use_simple_cache_;
106 bool is_disabled_; 111 bool is_disabled_;
112 bool is_waiting_to_initialize_;
107 net::CompletionCallback init_callback_; 113 net::CompletionCallback init_callback_;
108 scoped_refptr<CreateBackendCallbackShim> create_backend_callback_; 114 scoped_refptr<CreateBackendCallbackShim> create_backend_callback_;
109 PendingCalls pending_calls_; 115 PendingCalls pending_calls_;
110 OpenEntries open_entries_; 116 OpenEntries open_entries_;
111 scoped_ptr<disk_cache::Backend> disk_cache_; 117 scoped_ptr<disk_cache::Backend> disk_cache_;
112 118
113 base::WeakPtrFactory<AppCacheDiskCache> weak_factory_; 119 base::WeakPtrFactory<AppCacheDiskCache> weak_factory_;
114 }; 120 };
115 121
116 } // namespace content 122 } // namespace content
117 123
118 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_ 124 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698