| OLD | NEW |
| 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 "android_webview/browser/net_disk_cache_remover.h" | 5 #include "android_webview/browser/net_disk_cache_remover.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 11 #include "net/disk_cache/disk_cache.h" | 11 #include "net/disk_cache/disk_cache.h" |
| 12 #include "net/http/http_cache.h" | 12 #include "net/http/http_cache.h" |
| 13 #include "net/http/http_transaction_factory.h" | 13 #include "net/http/http_transaction_factory.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 using disk_cache::Backend; | 19 using disk_cache::Backend; |
| 20 using net::CompletionCallback; | 20 using net::CompletionCallback; |
| 21 using net::URLRequestContextGetter; | 21 using net::URLRequestContextGetter; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 // Everything is called and accessed on the IO thread. | 24 // Everything is called and accessed on the IO thread. |
| 25 | 25 |
| 26 void Noop(int rv) { | 26 void Noop(int rv) { |
| 27 DCHECK(rv == net::OK); | 27 DCHECK_EQ(net::OK, rv); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void CallDoomAllEntries(Backend** backend, int rv) { | 30 void CallDoomAllEntries(Backend** backend, int rv) { |
| 31 DCHECK(rv == net::OK); | 31 DCHECK_EQ(net::OK, rv); |
| 32 (*backend)->DoomAllEntries(base::Bind(&Noop)); | 32 (*backend)->DoomAllEntries(base::Bind(&Noop)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void ClearHttpDiskCacheOfContext(URLRequestContextGetter* context_getter) { | 35 void ClearHttpDiskCacheOfContext(URLRequestContextGetter* context_getter) { |
| 36 typedef Backend* BackendPtr; // Make line below easier to understand. | 36 typedef Backend* BackendPtr; // Make line below easier to understand. |
| 37 BackendPtr* backend_ptr = new BackendPtr(NULL); | 37 BackendPtr* backend_ptr = new BackendPtr(NULL); |
| 38 CompletionCallback callback(base::Bind(&CallDoomAllEntries, | 38 CompletionCallback callback(base::Bind(&CallDoomAllEntries, |
| 39 base::Owned(backend_ptr))); | 39 base::Owned(backend_ptr))); |
| 40 | 40 |
| 41 int rv = context_getter->GetURLRequestContext()-> | 41 int rv = context_getter->GetURLRequestContext()-> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 renderer_child_id); | 67 renderer_child_id); |
| 68 | 68 |
| 69 BrowserThread::PostTask( | 69 BrowserThread::PostTask( |
| 70 BrowserThread::IO, FROM_HERE, | 70 BrowserThread::IO, FROM_HERE, |
| 71 base::Bind(&ClearHttpDiskCacheOnIoThread, | 71 base::Bind(&ClearHttpDiskCacheOnIoThread, |
| 72 base::Unretained(main_context_getter), | 72 base::Unretained(main_context_getter), |
| 73 base::Unretained(media_context_getter))); | 73 base::Unretained(media_context_getter))); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace android_webview | 76 } // namespace android_webview |
| OLD | NEW |