| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "webkit/appcache/view_appcache_internals_job.h" | 8 #include "webkit/appcache/view_appcache_internals_job.h" |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/bind.h" |
| 11 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 12 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 19 #include "net/base/escape.h" | 20 #include "net/base/escape.h" |
| 20 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 394 } |
| 394 }; | 395 }; |
| 395 | 396 |
| 396 // Job that removes an appcache and then redirects back to the main page. | 397 // Job that removes an appcache and then redirects back to the main page. |
| 397 class RemoveAppCacheJob : public RedirectToMainPageJob { | 398 class RemoveAppCacheJob : public RedirectToMainPageJob { |
| 398 public: | 399 public: |
| 399 RemoveAppCacheJob( | 400 RemoveAppCacheJob( |
| 400 net::URLRequest* request, AppCacheService* service, | 401 net::URLRequest* request, AppCacheService* service, |
| 401 const GURL& manifest_url) | 402 const GURL& manifest_url) |
| 402 : RedirectToMainPageJob(request, service), | 403 : RedirectToMainPageJob(request, service), |
| 403 manifest_url_(manifest_url) {} | 404 manifest_url_(manifest_url), |
| 405 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 406 } |
| 404 | 407 |
| 405 virtual void Start() { | 408 virtual void Start() { |
| 406 DCHECK(request_); | 409 DCHECK(request_); |
| 407 delete_appcache_callback_ = | 410 |
| 408 new net::CancelableOldCompletionCallback<RemoveAppCacheJob>( | |
| 409 this, &RemoveAppCacheJob::OnDeleteAppCacheComplete); | |
| 410 appcache_service_->DeleteAppCacheGroup( | 411 appcache_service_->DeleteAppCacheGroup( |
| 411 manifest_url_, delete_appcache_callback_); | 412 manifest_url_,base::Bind(&RemoveAppCacheJob::OnDeleteAppCacheComplete, |
| 413 weak_factory_.GetWeakPtr())); |
| 412 } | 414 } |
| 413 | 415 |
| 414 private: | 416 private: |
| 415 virtual ~RemoveAppCacheJob() { | 417 virtual ~RemoveAppCacheJob() {} |
| 416 if (delete_appcache_callback_) | |
| 417 delete_appcache_callback_.release()->Cancel(); | |
| 418 } | |
| 419 | 418 |
| 420 void OnDeleteAppCacheComplete(int rv) { | 419 void OnDeleteAppCacheComplete(int rv) { |
| 421 delete_appcache_callback_ = NULL; | |
| 422 StartAsync(); // Causes the base class to redirect. | 420 StartAsync(); // Causes the base class to redirect. |
| 423 } | 421 } |
| 424 | 422 |
| 425 GURL manifest_url_; | 423 GURL manifest_url_; |
| 426 scoped_refptr<net::CancelableOldCompletionCallback<RemoveAppCacheJob> > | 424 base::WeakPtrFactory<RemoveAppCacheJob> weak_factory_; |
| 427 delete_appcache_callback_; | |
| 428 }; | 425 }; |
| 429 | 426 |
| 430 | 427 |
| 431 // Job shows the details of a particular manifest url. | 428 // Job shows the details of a particular manifest url. |
| 432 class ViewAppCacheJob : public BaseInternalsJob, | 429 class ViewAppCacheJob : public BaseInternalsJob, |
| 433 public AppCacheStorage::Delegate { | 430 public AppCacheStorage::Delegate { |
| 434 public: | 431 public: |
| 435 ViewAppCacheJob( | 432 ViewAppCacheJob( |
| 436 net::URLRequest* request, AppCacheService* service, | 433 net::URLRequest* request, AppCacheService* service, |
| 437 const GURL manifest_url) | 434 const GURL manifest_url) |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return new ViewEntryJob(request, service, | 614 return new ViewEntryJob(request, service, |
| 618 DecodeBase64URL(tokens[0]), // manifest url | 615 DecodeBase64URL(tokens[0]), // manifest url |
| 619 DecodeBase64URL(tokens[1]), // entry url | 616 DecodeBase64URL(tokens[1]), // entry url |
| 620 response_id, group_id); | 617 response_id, group_id); |
| 621 } | 618 } |
| 622 | 619 |
| 623 return new RedirectToMainPageJob(request, service); | 620 return new RedirectToMainPageJob(request, service); |
| 624 } | 621 } |
| 625 | 622 |
| 626 } // namespace appcache | 623 } // namespace appcache |
| OLD | NEW |