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

Side by Side Diff: webkit/browser/appcache/appcache_update_job.cc

Issue 22314003: NavigationController prototype Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NavController prototype - chrome side Created 7 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 unified diff | Download patch | Annotate | Revision Log
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/browser/appcache/appcache_update_job.h" 5 #include "webkit/browser/appcache/appcache_update_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service, 295 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
296 AppCacheGroup* group) 296 AppCacheGroup* group)
297 : service_(service), 297 : service_(service),
298 manifest_url_(group->manifest_url()), 298 manifest_url_(group->manifest_url()),
299 group_(group), 299 group_(group),
300 update_type_(UNKNOWN_TYPE), 300 update_type_(UNKNOWN_TYPE),
301 internal_state_(FETCH_MANIFEST), 301 internal_state_(FETCH_MANIFEST),
302 master_entries_completed_(0), 302 master_entries_completed_(0),
303 url_fetches_completed_(0), 303 url_fetches_completed_(0),
304 manifest_fetcher_(NULL), 304 manifest_fetcher_(NULL),
305 stored_state_(UNSTORED) { 305 stored_state_(UNSTORED),
306 using_fake_manifest_(false) {
306 } 307 }
307 308
308 AppCacheUpdateJob::~AppCacheUpdateJob() { 309 AppCacheUpdateJob::~AppCacheUpdateJob() {
309 if (internal_state_ != COMPLETED) 310 if (internal_state_ != COMPLETED)
310 Cancel(); 311 Cancel();
311 312
312 DCHECK(!manifest_fetcher_); 313 DCHECK(!manifest_fetcher_);
313 DCHECK(pending_url_fetches_.empty()); 314 DCHECK(pending_url_fetches_.empty());
314 DCHECK(!inprogress_cache_.get()); 315 DCHECK(!inprogress_cache_.get());
315 DCHECK(pending_master_entries_.empty()); 316 DCHECK(pending_master_entries_.empty());
316 DCHECK(master_entry_fetches_.empty()); 317 DCHECK(master_entry_fetches_.empty());
317 318
318 if (group_) 319 if (group_)
319 group_->SetUpdateStatus(AppCacheGroup::IDLE); 320 group_->SetUpdateStatus(AppCacheGroup::IDLE);
320 } 321 }
321 322
322 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host, 323 void AppCacheUpdateJob::StartUpdate(AppCacheHost* host,
323 const GURL& new_master_resource) { 324 const GURL& new_master_resource) {
324 DCHECK(group_->update_job() == this); 325 DCHECK(group_->update_job() == this);
325 DCHECK(!group_->is_obsolete()); 326 DCHECK(!group_->is_obsolete());
326 327
328 // Hackery for 'registerController'
329 if (group_->HasCache() &&
330 !group_->newest_complete_cache()->GetEntry(group_->manifest_url())) {
331 using_fake_manifest_ = true;
332 DeleteSoon();
333 return;
334 }
335
327 bool is_new_pending_master_entry = false; 336 bool is_new_pending_master_entry = false;
328 if (!new_master_resource.is_empty()) { 337 if (!new_master_resource.is_empty()) {
329 DCHECK(new_master_resource == host->pending_master_entry_url()); 338 DCHECK(new_master_resource == host->pending_master_entry_url());
330 DCHECK(!new_master_resource.has_ref()); 339 DCHECK(!new_master_resource.has_ref());
331 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin()); 340 DCHECK(new_master_resource.GetOrigin() == manifest_url_.GetOrigin());
332 341
333 // Cannot add more to this update if already terminating. 342 // Cannot add more to this update if already terminating.
334 if (IsTerminating()) { 343 if (IsTerminating()) {
335 group_->QueueUpdate(host, new_master_resource); 344 group_->QueueUpdate(host, new_master_resource);
336 return; 345 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 383 }
375 384
376 if (!new_master_resource.is_empty()) { 385 if (!new_master_resource.is_empty()) {
377 AddMasterEntryToFetchList(host, new_master_resource, 386 AddMasterEntryToFetchList(host, new_master_resource,
378 is_new_pending_master_entry); 387 is_new_pending_master_entry);
379 } 388 }
380 389
381 FetchManifest(true); 390 FetchManifest(true);
382 } 391 }
383 392
393 // Hackery for 'registerController'
394 void AppCacheUpdateJob::StartUpdateWithFakeManifest(Manifest* manifest) {
395 DCHECK(group_->update_job() == this);
396 DCHECK(!group_->is_obsolete());
397
398 using_fake_manifest_ = true;
399
400 // Begin the update process for the group.
401 group_->SetUpdateStatus(AppCacheGroup::CHECKING);
402 DCHECK(!group_->HasCache()); // we don't ever 'upgrade' these caches
403 update_type_ = CACHE_ATTEMPT;
404
405 // Jump straight into downloading the controller script.
406 internal_state_ = DOWNLOADING;
407 inprogress_cache_ = new AppCache(service_->storage(),
408 service_->storage()->NewCacheId());
409 BuildUrlFileList(*manifest);
410 inprogress_cache_->InitializeWithManifest(manifest);
411 group_->SetUpdateStatus(AppCacheGroup::DOWNLOADING);
412 NotifyAllAssociatedHosts(DOWNLOADING_EVENT);
413 FetchUrls();
414 }
415
384 AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() { 416 AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() {
385 AppCacheResponseWriter* writer = 417 AppCacheResponseWriter* writer =
386 service_->storage()->CreateResponseWriter(manifest_url_, 418 service_->storage()->CreateResponseWriter(manifest_url_,
387 group_->group_id()); 419 group_->group_id());
388 stored_response_ids_.push_back(writer->response_id()); 420 stored_response_ids_.push_back(writer->response_id());
389 return writer; 421 return writer;
390 } 422 }
391 423
392 void AppCacheUpdateJob::HandleCacheFailure(const std::string& error_message) { 424 void AppCacheUpdateJob::HandleCacheFailure(const std::string& error_message) {
393 // 6.9.4 cache failure steps 2-8. 425 // 6.9.4 cache failure steps 2-8.
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 void AppCacheUpdateJob::MaybeCompleteUpdate() { 1247 void AppCacheUpdateJob::MaybeCompleteUpdate() {
1216 DCHECK(internal_state_ != CACHE_FAILURE); 1248 DCHECK(internal_state_ != CACHE_FAILURE);
1217 1249
1218 // Must wait for any pending master entries or url fetches to complete. 1250 // Must wait for any pending master entries or url fetches to complete.
1219 if (master_entries_completed_ != pending_master_entries_.size() || 1251 if (master_entries_completed_ != pending_master_entries_.size() ||
1220 url_fetches_completed_ != url_file_list_.size()) { 1252 url_fetches_completed_ != url_file_list_.size()) {
1221 DCHECK(internal_state_ != COMPLETED); 1253 DCHECK(internal_state_ != COMPLETED);
1222 return; 1254 return;
1223 } 1255 }
1224 1256
1257 // Hackery for 'registerController'
1258 if (using_fake_manifest_) {
1259 if (stored_state_ == UNSTORED) {
1260 // Skip refetching the manifest that does not exist.
1261 StoreGroupAndCache();
1262 return;
1263 }
1264 if (stored_state_ == STORING)
1265 return;
1266 internal_state_ = REFETCH_MANIFEST; // hackery to fallthru to below
1267 }
1268
1225 switch (internal_state_) { 1269 switch (internal_state_) {
1226 case NO_UPDATE: 1270 case NO_UPDATE:
1227 if (master_entries_completed_ > 0) { 1271 if (master_entries_completed_ > 0) {
1228 switch (stored_state_) { 1272 switch (stored_state_) {
1229 case UNSTORED: 1273 case UNSTORED:
1230 StoreGroupAndCache(); 1274 StoreGroupAndCache();
1231 return; 1275 return;
1232 case STORING: 1276 case STORING:
1233 return; 1277 return;
1234 case STORED: 1278 case STORED:
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 1391
1348 // Break the connection with the group so the group cannot call delete 1392 // Break the connection with the group so the group cannot call delete
1349 // on this object after we've posted a task to delete ourselves. 1393 // on this object after we've posted a task to delete ourselves.
1350 group_->SetUpdateStatus(AppCacheGroup::IDLE); 1394 group_->SetUpdateStatus(AppCacheGroup::IDLE);
1351 group_ = NULL; 1395 group_ = NULL;
1352 1396
1353 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1397 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1354 } 1398 }
1355 1399
1356 } // namespace appcache 1400 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/browser/appcache/appcache_update_job.h ('k') | webkit/browser/appcache/appcache_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698