| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_host.h" | 5 #include "webkit/appcache/appcache_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" |
| 9 #include "webkit/appcache/appcache.h" | 10 #include "webkit/appcache/appcache.h" |
| 10 #include "webkit/appcache/appcache_backend_impl.h" | 11 #include "webkit/appcache/appcache_backend_impl.h" |
| 11 #include "webkit/appcache/appcache_request_handler.h" | 12 #include "webkit/appcache/appcache_request_handler.h" |
| 12 | 13 |
| 13 namespace appcache { | 14 namespace appcache { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 void FillCacheInfo( | 18 void FillCacheInfo( |
| 18 const AppCache* cache, Status status, AppCacheInfo* info) { | 19 const AppCache* cache, Status status, AppCacheInfo* info) { |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // with the application cache from which it was loaded. Invoke the | 351 // with the application cache from which it was loaded. Invoke the |
| 351 // application cache update process for that cache and with the browsing | 352 // application cache update process for that cache and with the browsing |
| 352 // context being navigated. | 353 // context being navigated. |
| 353 DCHECK(cache->owning_group()); | 354 DCHECK(cache->owning_group()); |
| 354 DCHECK(new_master_entry_url_.is_empty()); | 355 DCHECK(new_master_entry_url_.is_empty()); |
| 355 AppCacheGroup* owing_group = cache->owning_group(); | 356 AppCacheGroup* owing_group = cache->owning_group(); |
| 356 const char* kFormatString = | 357 const char* kFormatString = |
| 357 "Document was loaded from Application Cache with manifest %s"; | 358 "Document was loaded from Application Cache with manifest %s"; |
| 358 frontend_->OnLogMessage( | 359 frontend_->OnLogMessage( |
| 359 host_id_, LOG_INFO, | 360 host_id_, LOG_INFO, |
| 360 StringPrintf( | 361 base::StringPrintf( |
| 361 kFormatString, owing_group->manifest_url().spec().c_str())); | 362 kFormatString, owing_group->manifest_url().spec().c_str())); |
| 362 AssociateCache(cache); | 363 AssociateCache(cache); |
| 363 if (!owing_group->is_obsolete() && !owing_group->is_being_deleted()) { | 364 if (!owing_group->is_obsolete() && !owing_group->is_being_deleted()) { |
| 364 owing_group->StartUpdateWithHost(this); | 365 owing_group->StartUpdateWithHost(this); |
| 365 ObserveGroupBeingUpdated(owing_group); | 366 ObserveGroupBeingUpdated(owing_group); |
| 366 } | 367 } |
| 367 } else if (group && !group->is_being_deleted()) { | 368 } else if (group && !group->is_being_deleted()) { |
| 368 // If document was loaded using HTTP GET or equivalent, and, there is a | 369 // If document was loaded using HTTP GET or equivalent, and, there is a |
| 369 // manifest URL, and manifest URL has the same origin as document. | 370 // manifest URL, and manifest URL has the same origin as document. |
| 370 // Invoke the application cache update process for manifest URL, with | 371 // Invoke the application cache update process for manifest URL, with |
| 371 // the browsing context being navigated, and with document and the | 372 // the browsing context being navigated, and with document and the |
| 372 // resource from which document was loaded as the new master resourse. | 373 // resource from which document was loaded as the new master resourse. |
| 373 DCHECK(!group->is_obsolete()); | 374 DCHECK(!group->is_obsolete()); |
| 374 DCHECK(new_master_entry_url_.is_valid()); | 375 DCHECK(new_master_entry_url_.is_valid()); |
| 375 const char* kFormatString = group->HasCache() ? | 376 const char* kFormatString = group->HasCache() ? |
| 376 "Adding master entry to Application Cache with manifest %s" : | 377 "Adding master entry to Application Cache with manifest %s" : |
| 377 "Creating Application Cache with manifest %s"; | 378 "Creating Application Cache with manifest %s"; |
| 378 frontend_->OnLogMessage( | 379 frontend_->OnLogMessage( |
| 379 host_id_, LOG_INFO, | 380 host_id_, LOG_INFO, |
| 380 StringPrintf(kFormatString, group->manifest_url().spec().c_str())); | 381 base::StringPrintf(kFormatString, |
| 382 group->manifest_url().spec().c_str())); |
| 381 AssociateCache(NULL); // The UpdateJob may produce one for us later. | 383 AssociateCache(NULL); // The UpdateJob may produce one for us later. |
| 382 group->StartUpdateWithNewMasterEntry(this, new_master_entry_url_); | 384 group->StartUpdateWithNewMasterEntry(this, new_master_entry_url_); |
| 383 ObserveGroupBeingUpdated(group); | 385 ObserveGroupBeingUpdated(group); |
| 384 } else { | 386 } else { |
| 385 // Otherwise, the Document is not associated with any application cache. | 387 // Otherwise, the Document is not associated with any application cache. |
| 386 new_master_entry_url_ = GURL(); | 388 new_master_entry_url_ = GURL(); |
| 387 AssociateCache(NULL); | 389 AssociateCache(NULL); |
| 388 } | 390 } |
| 389 | 391 |
| 390 // Respond to pending callbacks now that we have a selection. | 392 // Respond to pending callbacks now that we have a selection. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 associated_cache_info_pending_ = cache && !cache->is_complete(); | 467 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 466 AppCacheInfo info; | 468 AppCacheInfo info; |
| 467 if (cache) { | 469 if (cache) { |
| 468 cache->AssociateHost(this); | 470 cache->AssociateHost(this); |
| 469 FillCacheInfo(cache, GetStatus(), &info); | 471 FillCacheInfo(cache, GetStatus(), &info); |
| 470 } | 472 } |
| 471 frontend_->OnCacheSelected(host_id_, info); | 473 frontend_->OnCacheSelected(host_id_, info); |
| 472 } | 474 } |
| 473 | 475 |
| 474 } // namespace appcache | 476 } // namespace appcache |
| OLD | NEW |