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

Side by Side Diff: chrome/browser/renderer_host/offline_resource_throttle.cc

Issue 9425026: Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix race condition Created 8 years, 10 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 "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/string_util.h" 13 #include "base/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 "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/browser/appcache/chrome_appcache_service.h"
18 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
19 #include "content/browser/renderer_host/resource_dispatcher_host.h" 18 #include "content/browser/renderer_host/resource_dispatcher_host.h"
20 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 19 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
21 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/render_view_host_delegate.h" 21 #include "content/public/browser/render_view_host_delegate.h"
22 #include "content/public/browser/resource_context.h"
23 #include "content/public/browser/resource_throttle_controller.h" 23 #include "content/public/browser/resource_throttle_controller.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/base/network_change_notifier.h" 25 #include "net/base/network_change_notifier.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
27 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
28 #include "webkit/appcache/appcache_service.h"
28 29
29 using content::BrowserThread; 30 using content::BrowserThread;
31 using content::ResourceContext;
30 using content::WebContents; 32 using content::WebContents;
31 33
32 namespace { 34 namespace {
33 35
34 void ShowOfflinePage( 36 void ShowOfflinePage(
35 int render_process_id, 37 int render_process_id,
36 int render_view_id, 38 int render_view_id,
37 const GURL& url, 39 const GURL& url,
38 const chromeos::OfflineLoadPage::CompletionCallback& callback) { 40 const chromeos::OfflineLoadPage::CompletionCallback& callback) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 14 matching lines...) Expand all
54 (new chromeos::OfflineLoadPage(web_contents, url, callback))->Show(); 56 (new chromeos::OfflineLoadPage(web_contents, url, callback))->Show();
55 } 57 }
56 } 58 }
57 59
58 } // namespace 60 } // namespace
59 61
60 OfflineResourceThrottle::OfflineResourceThrottle( 62 OfflineResourceThrottle::OfflineResourceThrottle(
61 int render_process_id, 63 int render_process_id,
62 int render_view_id, 64 int render_view_id,
63 net::URLRequest* request, 65 net::URLRequest* request,
64 ChromeAppCacheService* appcache_service) 66 content::ResourceContext* resource_context)
65 : render_process_id_(render_process_id), 67 : render_process_id_(render_process_id),
66 render_view_id_(render_view_id), 68 render_view_id_(render_view_id),
67 request_(request), 69 request_(request),
68 appcache_service_(appcache_service) { 70 resource_context_(resource_context) {
69 DCHECK(appcache_service_); 71 DCHECK(resource_context);
70 } 72 }
71 73
72 OfflineResourceThrottle::~OfflineResourceThrottle() { 74 OfflineResourceThrottle::~OfflineResourceThrottle() {
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
74 76
75 if (!appcache_completion_callback_.IsCancelled()) 77 if (!appcache_completion_callback_.IsCancelled())
76 appcache_completion_callback_.Cancel(); 78 appcache_completion_callback_.Cancel();
77 } 79 }
78 80
79 void OfflineResourceThrottle::WillStartRequest(bool* defer) { 81 void OfflineResourceThrottle::WillStartRequest(bool* defer) {
80 if (!ShouldShowOfflinePage(request_->url())) 82 if (!ShouldShowOfflinePage(request_->url()))
81 return; 83 return;
82 84
83 DVLOG(1) << "WillStartRequest: this=" << this << ", url=" << request_->url(); 85 DVLOG(1) << "WillStartRequest: this=" << this << ", url=" << request_->url();
84 86
85 DCHECK(appcache_completion_callback_.IsCancelled()); 87 DCHECK(appcache_completion_callback_.IsCancelled());
86 88
87 appcache_completion_callback_.Reset( 89 appcache_completion_callback_.Reset(
88 base::Bind(&OfflineResourceThrottle::OnCanHandleOfflineComplete, 90 base::Bind(&OfflineResourceThrottle::OnCanHandleOfflineComplete,
89 AsWeakPtr())); 91 AsWeakPtr()));
90 appcache_service_->CanHandleMainResourceOffline( 92 ResourceContext::GetAppCacheService(resource_context_)->
91 request_->url(), 93 CanHandleMainResourceOffline(
92 request_->first_party_for_cookies(), 94 request_->url(),
93 appcache_completion_callback_.callback()); 95 request_->first_party_for_cookies(),
96 appcache_completion_callback_.callback());
94 97
95 *defer = true; 98 *defer = true;
96 } 99 }
97 100
98 void OfflineResourceThrottle::OnBlockingPageComplete(bool proceed) { 101 void OfflineResourceThrottle::OnBlockingPageComplete(bool proceed) {
99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
100 103
101 if (proceed) { 104 if (proceed) {
102 controller()->Resume(); 105 controller()->Resume();
103 } else { 106 } else {
(...skipping 25 matching lines...) Expand all
129 base::Bind( 132 base::Bind(
130 &ShowOfflinePage, 133 &ShowOfflinePage,
131 render_process_id_, 134 render_process_id_,
132 render_view_id_, 135 render_view_id_,
133 request_->url(), 136 request_->url(),
134 base::Bind( 137 base::Bind(
135 &OfflineResourceThrottle::OnBlockingPageComplete, 138 &OfflineResourceThrottle::OnBlockingPageComplete,
136 AsWeakPtr()))); 139 AsWeakPtr())));
137 } 140 }
138 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698