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

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

Issue 7282054: Remove more unnecessary ChromeURLRequestContext members. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright and chormeos tests. Created 9 years, 5 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) 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 "chrome/browser/renderer_host/offline_resource_handler.h" 5 #include "chrome/browser/renderer_host/offline_resource_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/chromeos/network_state_notifier.h" 13 #include "chrome/browser/chromeos/network_state_notifier.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"
17 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
18 #include "content/browser/renderer_host/resource_dispatcher_host.h" 19 #include "content/browser/renderer_host/resource_dispatcher_host.h"
19 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 20 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/url_request/url_request.h" 22 #include "net/url_request/url_request.h"
22 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context.h"
23 24
24 OfflineResourceHandler::OfflineResourceHandler( 25 OfflineResourceHandler::OfflineResourceHandler(
25 ResourceHandler* handler, 26 ResourceHandler* handler,
26 int host_id, 27 int host_id,
27 int route_id, 28 int route_id,
28 ResourceDispatcherHost* rdh, 29 ResourceDispatcherHost* rdh,
29 net::URLRequest* request) 30 net::URLRequest* request,
31 ChromeAppCacheService* appcache_service)
30 : next_handler_(handler), 32 : next_handler_(handler),
31 process_host_id_(host_id), 33 process_host_id_(host_id),
32 render_view_id_(route_id), 34 render_view_id_(route_id),
33 rdh_(rdh), 35 rdh_(rdh),
34 request_(request), 36 request_(request),
37 appcache_service_(appcache_service),
35 deferred_request_id_(-1) { 38 deferred_request_id_(-1) {
39 DCHECK(appcache_service_);
36 } 40 }
37 41
38 OfflineResourceHandler::~OfflineResourceHandler() { 42 OfflineResourceHandler::~OfflineResourceHandler() {
39 DCHECK(!appcache_completion_callback_.get()); 43 DCHECK(!appcache_completion_callback_.get());
40 } 44 }
41 45
42 bool OfflineResourceHandler::OnUploadProgress(int request_id, 46 bool OfflineResourceHandler::OnUploadProgress(int request_id,
43 uint64 position, 47 uint64 position,
44 uint64 size) { 48 uint64 size) {
45 return next_handler_->OnUploadProgress(request_id, position, size); 49 return next_handler_->OnUploadProgress(request_id, position, size);
46 } 50 }
47 51
48 bool OfflineResourceHandler::OnRequestRedirected(int request_id, 52 bool OfflineResourceHandler::OnRequestRedirected(int request_id,
49 const GURL& new_url, 53 const GURL& new_url,
50 ResourceResponse* response, 54 ResourceResponse* response,
51 bool* defer) { 55 bool* defer) {
52 return next_handler_->OnRequestRedirected( 56 return next_handler_->OnRequestRedirected(
53 request_id, new_url, response, defer); 57 request_id, new_url, response, defer);
54 } 58 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (ShouldShowOfflinePage(url)) { 104 if (ShouldShowOfflinePage(url)) {
101 deferred_request_id_ = request_id; 105 deferred_request_id_ = request_id;
102 deferred_url_ = url; 106 deferred_url_ = url;
103 DVLOG(1) << "OnWillStart: this=" << this << ", request id=" << request_id 107 DVLOG(1) << "OnWillStart: this=" << this << ", request id=" << request_id
104 << ", url=" << url; 108 << ", url=" << url;
105 AddRef(); // Balanced with OnCanHandleOfflineComplete 109 AddRef(); // Balanced with OnCanHandleOfflineComplete
106 DCHECK(!appcache_completion_callback_); 110 DCHECK(!appcache_completion_callback_);
107 appcache_completion_callback_ = 111 appcache_completion_callback_ =
108 new net::CancelableCompletionCallback<OfflineResourceHandler>( 112 new net::CancelableCompletionCallback<OfflineResourceHandler>(
109 this, &OfflineResourceHandler::OnCanHandleOfflineComplete); 113 this, &OfflineResourceHandler::OnCanHandleOfflineComplete);
110 const ChromeURLRequestContext* url_request_context = 114 appcache_service_->CanHandleMainResourceOffline(
111 static_cast<const ChromeURLRequestContext*>(request_->context());
112 url_request_context->appcache_service()->CanHandleMainResourceOffline(
113 url, appcache_completion_callback_); 115 url, appcache_completion_callback_);
114 116
115 *defer = true; 117 *defer = true;
116 return true; 118 return true;
117 } 119 }
118 return next_handler_->OnWillStart(request_id, url, defer); 120 return next_handler_->OnWillStart(request_id, url, defer);
119 } 121 }
120 122
121 // We'll let the original event handler provide a buffer, and reuse it for 123 // We'll let the original event handler provide a buffer, and reuse it for
122 // subsequent reads until we're done buffering. 124 // subsequent reads until we're done buffering.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 DVLOG(1) << "Resume load: this=" << this << ", request id=" << request_id; 185 DVLOG(1) << "Resume load: this=" << this << ", request id=" << request_id;
184 next_handler_->OnWillStart(request_id, url, &defer); 186 next_handler_->OnWillStart(request_id, url, &defer);
185 if (!defer) 187 if (!defer)
186 rdh_->StartDeferredRequest(process_host_id_, request_id); 188 rdh_->StartDeferredRequest(process_host_id_, request_id);
187 } 189 }
188 190
189 void OfflineResourceHandler::ShowOfflinePage() { 191 void OfflineResourceHandler::ShowOfflinePage() {
190 chromeos::OfflineLoadPage::Show( 192 chromeos::OfflineLoadPage::Show(
191 process_host_id_, render_view_id_, deferred_url_, this); 193 process_host_id_, render_view_id_, deferred_url_, this);
192 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698