| 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 "chrome/browser/renderer_host/offline_resource_throttle.h" | 5 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "chrome/browser/chromeos/offline/offline_load_page.h" | 14 #include "chrome/browser/chromeos/offline/offline_load_page.h" |
| 15 #include "chrome/browser/net/chrome_url_request_context.h" | 15 #include "chrome/browser/net/chrome_url_request_context.h" |
| 16 #include "content/public/browser/appcache_service.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/resource_controller.h" | 19 #include "content/public/browser/resource_controller.h" |
| 19 #include "content/public/browser/resource_request_info.h" | 20 #include "content/public/browser/resource_request_info.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
| 24 #include "net/url_request/url_request.h" | 25 #include "net/url_request/url_request.h" |
| 25 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 26 #include "url/url_constants.h" | 27 #include "url/url_constants.h" |
| 27 #include "webkit/browser/appcache/appcache_service.h" | |
| 28 | 28 |
| 29 using content::BrowserThread; | 29 using content::BrowserThread; |
| 30 using content::RenderViewHost; | 30 using content::RenderViewHost; |
| 31 using content::WebContents; | 31 using content::WebContents; |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 void ShowOfflinePage( | 35 void ShowOfflinePage( |
| 36 int render_process_id, | 36 int render_process_id, |
| 37 int render_view_id, | 37 int render_view_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 53 // offline page here on the UI thread. | 53 // offline page here on the UI thread. |
| 54 if (web_contents) | 54 if (web_contents) |
| 55 (new chromeos::OfflineLoadPage(web_contents, url, callback))->Show(); | 55 (new chromeos::OfflineLoadPage(web_contents, url, callback))->Show(); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 OfflineResourceThrottle::OfflineResourceThrottle( | 61 OfflineResourceThrottle::OfflineResourceThrottle( |
| 62 net::URLRequest* request, | 62 net::URLRequest* request, |
| 63 appcache::AppCacheService* appcache_service) | 63 content::AppCacheService* appcache_service) |
| 64 : request_(request), | 64 : request_(request), |
| 65 appcache_service_(appcache_service) { | 65 appcache_service_(appcache_service) { |
| 66 DCHECK(appcache_service); | 66 DCHECK(appcache_service); |
| 67 } | 67 } |
| 68 | 68 |
| 69 OfflineResourceThrottle::~OfflineResourceThrottle() { | 69 OfflineResourceThrottle::~OfflineResourceThrottle() { |
| 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 71 | 71 |
| 72 if (!appcache_completion_callback_.IsCancelled()) | 72 if (!appcache_completion_callback_.IsCancelled()) |
| 73 appcache_completion_callback_.Cancel(); | 73 appcache_completion_callback_.Cancel(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 base::Bind( | 143 base::Bind( |
| 144 &ShowOfflinePage, | 144 &ShowOfflinePage, |
| 145 info->GetChildID(), | 145 info->GetChildID(), |
| 146 info->GetRouteID(), | 146 info->GetRouteID(), |
| 147 request_->url(), | 147 request_->url(), |
| 148 base::Bind( | 148 base::Bind( |
| 149 &OfflineResourceThrottle::OnBlockingPageComplete, | 149 &OfflineResourceThrottle::OnBlockingPageComplete, |
| 150 AsWeakPtr()))); | 150 AsWeakPtr()))); |
| 151 } | 151 } |
| 152 } | 152 } |
| OLD | NEW |