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

Side by Side Diff: webkit/appcache/appcache_storage_impl.cc

Issue 10066044: RefCounted types should not have public destructors, webkit/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation ordering Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_service.h ('k') | webkit/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webkit/appcache/appcache_storage_impl.h" 5 #include "webkit/appcache/appcache_storage_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 class AppCacheStorageImpl::DatabaseTask 142 class AppCacheStorageImpl::DatabaseTask
143 : public base::RefCountedThreadSafe<DatabaseTask> { 143 : public base::RefCountedThreadSafe<DatabaseTask> {
144 public: 144 public:
145 explicit DatabaseTask(AppCacheStorageImpl* storage) 145 explicit DatabaseTask(AppCacheStorageImpl* storage)
146 : storage_(storage), database_(storage->database_), 146 : storage_(storage), database_(storage->database_),
147 io_thread_(base::MessageLoopProxy::current()) { 147 io_thread_(base::MessageLoopProxy::current()) {
148 DCHECK(io_thread_); 148 DCHECK(io_thread_);
149 } 149 }
150 150
151 virtual ~DatabaseTask() {}
152
153 void AddDelegate(DelegateReference* delegate_reference) { 151 void AddDelegate(DelegateReference* delegate_reference) {
154 delegates_.push_back(make_scoped_refptr(delegate_reference)); 152 delegates_.push_back(make_scoped_refptr(delegate_reference));
155 } 153 }
156 154
157 // Schedules a task to be Run() on the DB thread. Tasks 155 // Schedules a task to be Run() on the DB thread. Tasks
158 // are run in the order in which they are scheduled. 156 // are run in the order in which they are scheduled.
159 void Schedule(); 157 void Schedule();
160 158
161 // Called on the DB thread. 159 // Called on the DB thread.
162 virtual void Run() = 0; 160 virtual void Run() = 0;
163 161
164 // Called on the IO thread after Run() has completed. 162 // Called on the IO thread after Run() has completed.
165 virtual void RunCompleted() {} 163 virtual void RunCompleted() {}
166 164
167 // Once scheduled a task cannot be cancelled, but the 165 // Once scheduled a task cannot be cancelled, but the
168 // call to RunCompleted may be. This method should only be 166 // call to RunCompleted may be. This method should only be
169 // called on the IO thread. This is used by AppCacheStorageImpl 167 // called on the IO thread. This is used by AppCacheStorageImpl
170 // to cancel the completion calls when AppCacheStorageImpl is 168 // to cancel the completion calls when AppCacheStorageImpl is
171 // destructed. This method may be overriden to release or delete 169 // destructed. This method may be overriden to release or delete
172 // additional data associated with the task that is not DB thread 170 // additional data associated with the task that is not DB thread
173 // safe. If overriden, this base class method must be called from 171 // safe. If overriden, this base class method must be called from
174 // within the override. 172 // within the override.
175 virtual void CancelCompletion(); 173 virtual void CancelCompletion();
176 174
177 protected: 175 protected:
176 friend class base::RefCountedThreadSafe<DatabaseTask>;
177 virtual ~DatabaseTask() {}
178
178 AppCacheStorageImpl* storage_; 179 AppCacheStorageImpl* storage_;
179 AppCacheDatabase* database_; 180 AppCacheDatabase* database_;
180 DelegateReferenceVector delegates_; 181 DelegateReferenceVector delegates_;
181 182
182 private: 183 private:
183 void CallRun(base::TimeTicks schedule_time); 184 void CallRun(base::TimeTicks schedule_time);
184 void CallRunCompleted(base::TimeTicks schedule_time); 185 void CallRunCompleted(base::TimeTicks schedule_time);
185 void CallDisableStorage(); 186 void CallDisableStorage();
186 187
187 scoped_refptr<base::MessageLoopProxy> io_thread_; 188 scoped_refptr<base::MessageLoopProxy> io_thread_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 252
252 // InitTask ------- 253 // InitTask -------
253 254
254 class AppCacheStorageImpl::InitTask : public DatabaseTask { 255 class AppCacheStorageImpl::InitTask : public DatabaseTask {
255 public: 256 public:
256 explicit InitTask(AppCacheStorageImpl* storage) 257 explicit InitTask(AppCacheStorageImpl* storage)
257 : DatabaseTask(storage), last_group_id_(0), 258 : DatabaseTask(storage), last_group_id_(0),
258 last_cache_id_(0), last_response_id_(0), 259 last_cache_id_(0), last_response_id_(0),
259 last_deletable_response_rowid_(0) {} 260 last_deletable_response_rowid_(0) {}
260 261
261 virtual void Run(); 262 // DatabaseTask:
262 virtual void RunCompleted(); 263 virtual void Run() OVERRIDE;
264 virtual void RunCompleted() OVERRIDE;
263 265
266 protected:
267 virtual ~InitTask() {}
268
269 private:
264 int64 last_group_id_; 270 int64 last_group_id_;
265 int64 last_cache_id_; 271 int64 last_cache_id_;
266 int64 last_response_id_; 272 int64 last_response_id_;
267 int64 last_deletable_response_rowid_; 273 int64 last_deletable_response_rowid_;
268 std::map<GURL, int64> usage_map_; 274 std::map<GURL, int64> usage_map_;
269 }; 275 };
270 276
271 void AppCacheStorageImpl::InitTask::Run() { 277 void AppCacheStorageImpl::InitTask::Run() {
272 database_->FindLastStorageIds( 278 database_->FindLastStorageIds(
273 &last_group_id_, &last_cache_id_, &last_response_id_, 279 &last_group_id_, &last_cache_id_, &last_response_id_,
(...skipping 21 matching lines...) Expand all
295 storage_->service()->quota_client()->NotifyAppCacheReady(); 301 storage_->service()->quota_client()->NotifyAppCacheReady();
296 } 302 }
297 303
298 // CloseConnectionTask ------- 304 // CloseConnectionTask -------
299 305
300 class AppCacheStorageImpl::CloseConnectionTask : public DatabaseTask { 306 class AppCacheStorageImpl::CloseConnectionTask : public DatabaseTask {
301 public: 307 public:
302 explicit CloseConnectionTask(AppCacheStorageImpl* storage) 308 explicit CloseConnectionTask(AppCacheStorageImpl* storage)
303 : DatabaseTask(storage) {} 309 : DatabaseTask(storage) {}
304 310
305 virtual void Run() { database_->CloseConnection(); } 311 // DatabaseTask:
312 virtual void Run() OVERRIDE { database_->CloseConnection(); }
313
314 protected:
315 virtual ~CloseConnectionTask() {}
306 }; 316 };
307 317
308 // DisableDatabaseTask ------- 318 // DisableDatabaseTask -------
309 319
310 class AppCacheStorageImpl::DisableDatabaseTask : public DatabaseTask { 320 class AppCacheStorageImpl::DisableDatabaseTask : public DatabaseTask {
311 public: 321 public:
312 explicit DisableDatabaseTask(AppCacheStorageImpl* storage) 322 explicit DisableDatabaseTask(AppCacheStorageImpl* storage)
313 : DatabaseTask(storage) {} 323 : DatabaseTask(storage) {}
314 324
315 virtual void Run() { database_->Disable(); } 325 // DatabaseTask:
326 virtual void Run() OVERRIDE { database_->Disable(); }
327
328 protected:
329 virtual ~DisableDatabaseTask() {}
316 }; 330 };
317 331
318 // GetAllInfoTask ------- 332 // GetAllInfoTask -------
319 333
320 class AppCacheStorageImpl::GetAllInfoTask : public DatabaseTask { 334 class AppCacheStorageImpl::GetAllInfoTask : public DatabaseTask {
321 public: 335 public:
322 explicit GetAllInfoTask(AppCacheStorageImpl* storage) 336 explicit GetAllInfoTask(AppCacheStorageImpl* storage)
323 : DatabaseTask(storage), 337 : DatabaseTask(storage),
324 info_collection_(new AppCacheInfoCollection()) { 338 info_collection_(new AppCacheInfoCollection()) {
325 } 339 }
326 340
327 virtual void Run(); 341 // DatabaseTask:
328 virtual void RunCompleted(); 342 virtual void Run() OVERRIDE;
343 virtual void RunCompleted() OVERRIDE;
329 344
345 protected:
346 virtual ~GetAllInfoTask() {}
347
348 private:
330 scoped_refptr<AppCacheInfoCollection> info_collection_; 349 scoped_refptr<AppCacheInfoCollection> info_collection_;
331 }; 350 };
332 351
333 void AppCacheStorageImpl::GetAllInfoTask::Run() { 352 void AppCacheStorageImpl::GetAllInfoTask::Run() {
334 std::set<GURL> origins; 353 std::set<GURL> origins;
335 database_->FindOriginsWithGroups(&origins); 354 database_->FindOriginsWithGroups(&origins);
336 for (std::set<GURL>::const_iterator origin = origins.begin(); 355 for (std::set<GURL>::const_iterator origin = origins.begin();
337 origin != origins.end(); ++origin) { 356 origin != origins.end(); ++origin) {
338 AppCacheInfoVector& infos = 357 AppCacheInfoVector& infos =
339 info_collection_->infos_by_origin[*origin]; 358 info_collection_->infos_by_origin[*origin];
(...skipping 22 matching lines...) Expand all
362 DCHECK(delegates_.size() == 1); 381 DCHECK(delegates_.size() == 1);
363 FOR_EACH_DELEGATE(delegates_, OnAllInfo(info_collection_)); 382 FOR_EACH_DELEGATE(delegates_, OnAllInfo(info_collection_));
364 } 383 }
365 384
366 // StoreOrLoadTask ------- 385 // StoreOrLoadTask -------
367 386
368 class AppCacheStorageImpl::StoreOrLoadTask : public DatabaseTask { 387 class AppCacheStorageImpl::StoreOrLoadTask : public DatabaseTask {
369 protected: 388 protected:
370 explicit StoreOrLoadTask(AppCacheStorageImpl* storage) 389 explicit StoreOrLoadTask(AppCacheStorageImpl* storage)
371 : DatabaseTask(storage) {} 390 : DatabaseTask(storage) {}
391 virtual ~StoreOrLoadTask() {}
372 392
373 bool FindRelatedCacheRecords(int64 cache_id); 393 bool FindRelatedCacheRecords(int64 cache_id);
374 void CreateCacheAndGroupFromRecords( 394 void CreateCacheAndGroupFromRecords(
375 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group); 395 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group);
376 396
377 AppCacheDatabase::GroupRecord group_record_; 397 AppCacheDatabase::GroupRecord group_record_;
378 AppCacheDatabase::CacheRecord cache_record_; 398 AppCacheDatabase::CacheRecord cache_record_;
379 std::vector<AppCacheDatabase::EntryRecord> entry_records_; 399 std::vector<AppCacheDatabase::EntryRecord> entry_records_;
380 std::vector<AppCacheDatabase::NamespaceRecord> 400 std::vector<AppCacheDatabase::NamespaceRecord>
381 intercept_namespace_records_; 401 intercept_namespace_records_;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 466 }
447 467
448 // CacheLoadTask ------- 468 // CacheLoadTask -------
449 469
450 class AppCacheStorageImpl::CacheLoadTask : public StoreOrLoadTask { 470 class AppCacheStorageImpl::CacheLoadTask : public StoreOrLoadTask {
451 public: 471 public:
452 CacheLoadTask(int64 cache_id, AppCacheStorageImpl* storage) 472 CacheLoadTask(int64 cache_id, AppCacheStorageImpl* storage)
453 : StoreOrLoadTask(storage), cache_id_(cache_id), 473 : StoreOrLoadTask(storage), cache_id_(cache_id),
454 success_(false) {} 474 success_(false) {}
455 475
456 virtual void Run(); 476 // DatabaseTask:
457 virtual void RunCompleted(); 477 virtual void Run() OVERRIDE;
478 virtual void RunCompleted() OVERRIDE;
458 479
480 protected:
481 virtual ~CacheLoadTask() {}
482
483 private:
459 int64 cache_id_; 484 int64 cache_id_;
460 bool success_; 485 bool success_;
461 }; 486 };
462 487
463 void AppCacheStorageImpl::CacheLoadTask::Run() { 488 void AppCacheStorageImpl::CacheLoadTask::Run() {
464 success_ = 489 success_ =
465 database_->FindCache(cache_id_, &cache_record_) && 490 database_->FindCache(cache_id_, &cache_record_) &&
466 database_->FindGroup(cache_record_.group_id, &group_record_) && 491 database_->FindGroup(cache_record_.group_id, &group_record_) &&
467 FindRelatedCacheRecords(cache_id_); 492 FindRelatedCacheRecords(cache_id_);
468 493
(...skipping 14 matching lines...) Expand all
483 } 508 }
484 509
485 // GroupLoadTask ------- 510 // GroupLoadTask -------
486 511
487 class AppCacheStorageImpl::GroupLoadTask : public StoreOrLoadTask { 512 class AppCacheStorageImpl::GroupLoadTask : public StoreOrLoadTask {
488 public: 513 public:
489 GroupLoadTask(GURL manifest_url, AppCacheStorageImpl* storage) 514 GroupLoadTask(GURL manifest_url, AppCacheStorageImpl* storage)
490 : StoreOrLoadTask(storage), manifest_url_(manifest_url), 515 : StoreOrLoadTask(storage), manifest_url_(manifest_url),
491 success_(false) {} 516 success_(false) {}
492 517
493 virtual void Run(); 518 // DatabaseTask:
494 virtual void RunCompleted(); 519 virtual void Run() OVERRIDE;
520 virtual void RunCompleted() OVERRIDE;
495 521
522 protected:
523 virtual ~GroupLoadTask() {}
524
525 private:
496 GURL manifest_url_; 526 GURL manifest_url_;
497 bool success_; 527 bool success_;
498 }; 528 };
499 529
500 void AppCacheStorageImpl::GroupLoadTask::Run() { 530 void AppCacheStorageImpl::GroupLoadTask::Run() {
501 success_ = 531 success_ =
502 database_->FindGroupForManifestUrl(manifest_url_, &group_record_) && 532 database_->FindGroupForManifestUrl(manifest_url_, &group_record_) &&
503 database_->FindCacheForGroup(group_record_.group_id, &cache_record_) && 533 database_->FindCacheForGroup(group_record_.group_id, &cache_record_) &&
504 FindRelatedCacheRecords(cache_record_.cache_id); 534 FindRelatedCacheRecords(cache_record_.cache_id);
505 535
(...skipping 25 matching lines...) Expand all
531 561
532 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask { 562 class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask {
533 public: 563 public:
534 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group, 564 StoreGroupAndCacheTask(AppCacheStorageImpl* storage, AppCacheGroup* group,
535 AppCache* newest_cache); 565 AppCache* newest_cache);
536 566
537 void GetQuotaThenSchedule(); 567 void GetQuotaThenSchedule();
538 void OnQuotaCallback( 568 void OnQuotaCallback(
539 quota::QuotaStatusCode status, int64 usage, int64 quota); 569 quota::QuotaStatusCode status, int64 usage, int64 quota);
540 570
541 virtual void Run(); 571 // DatabaseTask:
542 virtual void RunCompleted(); 572 virtual void Run() OVERRIDE;
543 virtual void CancelCompletion(); 573 virtual void RunCompleted() OVERRIDE;
574 virtual void CancelCompletion() OVERRIDE;
544 575
576 protected:
577 virtual ~StoreGroupAndCacheTask() {}
578
579 private:
545 scoped_refptr<AppCacheGroup> group_; 580 scoped_refptr<AppCacheGroup> group_;
546 scoped_refptr<AppCache> cache_; 581 scoped_refptr<AppCache> cache_;
547 bool success_; 582 bool success_;
548 bool would_exceed_quota_; 583 bool would_exceed_quota_;
549 int64 space_available_; 584 int64 space_available_;
550 int64 new_origin_usage_; 585 int64 new_origin_usage_;
551 std::vector<int64> newly_deletable_response_ids_; 586 std::vector<int64> newly_deletable_response_ids_;
552 }; 587 };
553 588
554 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( 589 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask(
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 it != groups_in_use->end(); ++it) { 860 it != groups_in_use->end(); ++it) {
826 AppCacheGroup* group = it->second; 861 AppCacheGroup* group = it->second;
827 AppCache* cache = group->newest_complete_cache(); 862 AppCache* cache = group->newest_complete_cache();
828 if (group->is_obsolete() || !cache) 863 if (group->is_obsolete() || !cache)
829 continue; 864 continue;
830 cache_ids_in_use_.insert(cache->cache_id()); 865 cache_ids_in_use_.insert(cache->cache_id());
831 } 866 }
832 } 867 }
833 } 868 }
834 869
835 virtual void Run(); 870 // DatabaseTask:
836 virtual void RunCompleted(); 871 virtual void Run() OVERRIDE;
872 virtual void RunCompleted() OVERRIDE;
873
874 protected:
875 virtual ~FindMainResponseTask() {}
837 876
838 private: 877 private:
839 typedef std::vector<AppCacheDatabase::NamespaceRecord*> 878 typedef std::vector<AppCacheDatabase::NamespaceRecord*>
840 NamespaceRecordPtrVector; 879 NamespaceRecordPtrVector;
880
841 bool FindExactMatch(int64 preferred_id); 881 bool FindExactMatch(int64 preferred_id);
842 bool FindNamespaceMatch(int64 preferred_id); 882 bool FindNamespaceMatch(int64 preferred_id);
843 bool FindNamespaceHelper( 883 bool FindNamespaceHelper(
844 int64 preferred_cache_id, 884 int64 preferred_cache_id,
845 AppCacheDatabase::NamespaceRecordVector* namespaces, 885 AppCacheDatabase::NamespaceRecordVector* namespaces,
846 NetworkNamespaceHelper* network_namespace_helper); 886 NetworkNamespaceHelper* network_namespace_helper);
847 bool FindFirstValidNamespace(const NamespaceRecordPtrVector& namespaces); 887 bool FindFirstValidNamespace(const NamespaceRecordPtrVector& namespaces);
848 888
849 GURL url_; 889 GURL url_;
850 GURL preferred_manifest_url_; 890 GURL preferred_manifest_url_;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 } 1063 }
1024 1064
1025 // MarkEntryAsForeignTask ------- 1065 // MarkEntryAsForeignTask -------
1026 1066
1027 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask { 1067 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask {
1028 public: 1068 public:
1029 MarkEntryAsForeignTask( 1069 MarkEntryAsForeignTask(
1030 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id) 1070 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id)
1031 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {} 1071 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {}
1032 1072
1033 virtual void Run(); 1073 // DatabaseTask:
1034 virtual void RunCompleted(); 1074 virtual void Run() OVERRIDE;
1075 virtual void RunCompleted() OVERRIDE;
1035 1076
1077 protected:
1078 virtual ~MarkEntryAsForeignTask() {}
1079
1080 private:
1036 int64 cache_id_; 1081 int64 cache_id_;
1037 GURL entry_url_; 1082 GURL entry_url_;
1038 }; 1083 };
1039 1084
1040 void AppCacheStorageImpl::MarkEntryAsForeignTask::Run() { 1085 void AppCacheStorageImpl::MarkEntryAsForeignTask::Run() {
1041 database_->AddEntryFlags(entry_url_, cache_id_, AppCacheEntry::FOREIGN); 1086 database_->AddEntryFlags(entry_url_, cache_id_, AppCacheEntry::FOREIGN);
1042 } 1087 }
1043 1088
1044 void AppCacheStorageImpl::MarkEntryAsForeignTask::RunCompleted() { 1089 void AppCacheStorageImpl::MarkEntryAsForeignTask::RunCompleted() {
1045 DCHECK(storage_->pending_foreign_markings_.front().first == entry_url_ && 1090 DCHECK(storage_->pending_foreign_markings_.front().first == entry_url_ &&
1046 storage_->pending_foreign_markings_.front().second == cache_id_); 1091 storage_->pending_foreign_markings_.front().second == cache_id_);
1047 storage_->pending_foreign_markings_.pop_front(); 1092 storage_->pending_foreign_markings_.pop_front();
1048 } 1093 }
1049 1094
1050 // MakeGroupObsoleteTask ------- 1095 // MakeGroupObsoleteTask -------
1051 1096
1052 class AppCacheStorageImpl::MakeGroupObsoleteTask : public DatabaseTask { 1097 class AppCacheStorageImpl::MakeGroupObsoleteTask : public DatabaseTask {
1053 public: 1098 public:
1054 MakeGroupObsoleteTask(AppCacheStorageImpl* storage, AppCacheGroup* group); 1099 MakeGroupObsoleteTask(AppCacheStorageImpl* storage, AppCacheGroup* group);
1055 1100
1056 virtual void Run(); 1101 // DatabaseTask:
1057 virtual void RunCompleted(); 1102 virtual void Run() OVERRIDE;
1058 virtual void CancelCompletion(); 1103 virtual void RunCompleted() OVERRIDE;
1104 virtual void CancelCompletion() OVERRIDE;
1059 1105
1106 protected:
1107 virtual ~MakeGroupObsoleteTask() {}
1108
1109 private:
1060 scoped_refptr<AppCacheGroup> group_; 1110 scoped_refptr<AppCacheGroup> group_;
1061 int64 group_id_; 1111 int64 group_id_;
1062 GURL origin_; 1112 GURL origin_;
1063 bool success_; 1113 bool success_;
1064 int64 new_origin_usage_; 1114 int64 new_origin_usage_;
1065 std::vector<int64> newly_deletable_response_ids_; 1115 std::vector<int64> newly_deletable_response_ids_;
1066 }; 1116 };
1067 1117
1068 AppCacheStorageImpl::MakeGroupObsoleteTask::MakeGroupObsoleteTask( 1118 AppCacheStorageImpl::MakeGroupObsoleteTask::MakeGroupObsoleteTask(
1069 AppCacheStorageImpl* storage, AppCacheGroup* group) 1119 AppCacheStorageImpl* storage, AppCacheGroup* group)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 group_ = NULL; 1173 group_ = NULL;
1124 } 1174 }
1125 1175
1126 // GetDeletableResponseIdsTask ------- 1176 // GetDeletableResponseIdsTask -------
1127 1177
1128 class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask { 1178 class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask {
1129 public: 1179 public:
1130 GetDeletableResponseIdsTask(AppCacheStorageImpl* storage, int64 max_rowid) 1180 GetDeletableResponseIdsTask(AppCacheStorageImpl* storage, int64 max_rowid)
1131 : DatabaseTask(storage), max_rowid_(max_rowid) {} 1181 : DatabaseTask(storage), max_rowid_(max_rowid) {}
1132 1182
1133 virtual void Run(); 1183 // DatabaseTask:
1134 virtual void RunCompleted(); 1184 virtual void Run() OVERRIDE;
1185 virtual void RunCompleted() OVERRIDE;
1135 1186
1187 protected:
1188 virtual ~GetDeletableResponseIdsTask() {}
1189
1190 private:
1136 int64 max_rowid_; 1191 int64 max_rowid_;
1137 std::vector<int64> response_ids_; 1192 std::vector<int64> response_ids_;
1138 }; 1193 };
1139 1194
1140 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() { 1195 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() {
1141 const int kSqlLimit = 1000; 1196 const int kSqlLimit = 1000;
1142 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit); 1197 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit);
1143 // TODO(michaeln): retrieve group_ids too 1198 // TODO(michaeln): retrieve group_ids too
1144 } 1199 }
1145 1200
1146 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() { 1201 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() {
1147 if (!response_ids_.empty()) 1202 if (!response_ids_.empty())
1148 storage_->StartDeletingResponses(response_ids_); 1203 storage_->StartDeletingResponses(response_ids_);
1149 } 1204 }
1150 1205
1151 // InsertDeletableResponseIdsTask ------- 1206 // InsertDeletableResponseIdsTask -------
1152 1207
1153 class AppCacheStorageImpl::InsertDeletableResponseIdsTask 1208 class AppCacheStorageImpl::InsertDeletableResponseIdsTask
1154 : public DatabaseTask { 1209 : public DatabaseTask {
1155 public: 1210 public:
1156 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1211 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1157 : DatabaseTask(storage) {} 1212 : DatabaseTask(storage) {}
1158 virtual void Run(); 1213
1214 // DatabaseTask:
1215 virtual void Run() OVERRIDE;
1216
1159 std::vector<int64> response_ids_; 1217 std::vector<int64> response_ids_;
1218
1219 protected:
1220 virtual ~InsertDeletableResponseIdsTask() {}
1160 }; 1221 };
1161 1222
1162 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() { 1223 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() {
1163 database_->InsertDeletableResponseIds(response_ids_); 1224 database_->InsertDeletableResponseIds(response_ids_);
1164 // TODO(michaeln): store group_ids too 1225 // TODO(michaeln): store group_ids too
1165 } 1226 }
1166 1227
1167 // DeleteDeletableResponseIdsTask ------- 1228 // DeleteDeletableResponseIdsTask -------
1168 1229
1169 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask 1230 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask
1170 : public DatabaseTask { 1231 : public DatabaseTask {
1171 public: 1232 public:
1172 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1233 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1173 : DatabaseTask(storage) {} 1234 : DatabaseTask(storage) {}
1174 virtual void Run(); 1235
1236 // DatabaseTask:
1237 virtual void Run() OVERRIDE;
1238
1175 std::vector<int64> response_ids_; 1239 std::vector<int64> response_ids_;
1240
1241 protected:
1242 virtual ~DeleteDeletableResponseIdsTask() {}
1176 }; 1243 };
1177 1244
1178 void AppCacheStorageImpl::DeleteDeletableResponseIdsTask::Run() { 1245 void AppCacheStorageImpl::DeleteDeletableResponseIdsTask::Run() {
1179 database_->DeleteDeletableResponseIds(response_ids_); 1246 database_->DeleteDeletableResponseIds(response_ids_);
1180 } 1247 }
1181 1248
1182 // UpdateGroupLastAccessTimeTask ------- 1249 // UpdateGroupLastAccessTimeTask -------
1183 1250
1184 class AppCacheStorageImpl::UpdateGroupLastAccessTimeTask 1251 class AppCacheStorageImpl::UpdateGroupLastAccessTimeTask
1185 : public DatabaseTask { 1252 : public DatabaseTask {
1186 public: 1253 public:
1187 UpdateGroupLastAccessTimeTask( 1254 UpdateGroupLastAccessTimeTask(
1188 AppCacheStorageImpl* storage, AppCacheGroup* group, base::Time time) 1255 AppCacheStorageImpl* storage, AppCacheGroup* group, base::Time time)
1189 : DatabaseTask(storage), group_id_(group->group_id()), 1256 : DatabaseTask(storage), group_id_(group->group_id()),
1190 last_access_time_(time) { 1257 last_access_time_(time) {
1191 storage->NotifyStorageAccessed(group->manifest_url().GetOrigin()); 1258 storage->NotifyStorageAccessed(group->manifest_url().GetOrigin());
1192 } 1259 }
1193 1260
1194 virtual void Run(); 1261 // DatabaseTask:
1262 virtual void Run() OVERRIDE;
1195 1263
1264 protected:
1265 virtual ~UpdateGroupLastAccessTimeTask() {}
1266
1267 private:
1196 int64 group_id_; 1268 int64 group_id_;
1197 base::Time last_access_time_; 1269 base::Time last_access_time_;
1198 }; 1270 };
1199 1271
1200 void AppCacheStorageImpl::UpdateGroupLastAccessTimeTask::Run() { 1272 void AppCacheStorageImpl::UpdateGroupLastAccessTimeTask::Run() {
1201 database_->UpdateGroupLastAccessTime(group_id_, last_access_time_); 1273 database_->UpdateGroupLastAccessTime(group_id_, last_access_time_);
1202 } 1274 }
1203 1275
1204 1276
1205 // AppCacheStorageImpl --------------------------------------------------- 1277 // AppCacheStorageImpl ---------------------------------------------------
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 Disable(); 1788 Disable();
1717 if (!is_incognito_) { 1789 if (!is_incognito_) {
1718 VLOG(1) << "Deleting existing appcache data and starting over."; 1790 VLOG(1) << "Deleting existing appcache data and starting over.";
1719 db_thread_->PostTask( 1791 db_thread_->PostTask(
1720 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); 1792 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_));
1721 } 1793 }
1722 } 1794 }
1723 } 1795 }
1724 1796
1725 } // namespace appcache 1797 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_service.h ('k') | webkit/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698