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 "chrome/browser/net/view_http_cache_job_factory.h" | 5 #include "chrome/browser/net/view_http_cache_job_factory.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 NotifyHeadersComplete(); | 120 NotifyHeadersComplete(); |
121 } | 121 } |
122 | 122 |
123 int ViewHttpCacheJob::Core::Start(const net::URLRequest& request, | 123 int ViewHttpCacheJob::Core::Start(const net::URLRequest& request, |
124 Callback0::Type* callback) { | 124 Callback0::Type* callback) { |
125 DCHECK(callback); | 125 DCHECK(callback); |
126 DCHECK(!user_callback_); | 126 DCHECK(!user_callback_); |
127 | 127 |
128 AddRef(); // Released on OnIOComplete(). | 128 AddRef(); // Released on OnIOComplete(). |
129 std::string cache_key = | 129 std::string cache_key = |
130 request.url().spec().substr(strlen(chrome::kNetworkViewCacheURL)); | 130 request.url().spec().substr(strlen(chrome::kChromeUINetworkViewCacheURL)); |
131 | 131 |
132 int rv; | 132 int rv; |
133 if (cache_key.empty()) { | 133 if (cache_key.empty()) { |
134 rv = cache_helper_.GetContentsHTML(request.context(), | 134 rv = cache_helper_.GetContentsHTML(request.context(), |
135 chrome::kNetworkViewCacheURL, &data_, | 135 chrome::kChromeUINetworkViewCacheURL, |
| 136 &data_, |
136 &callback_); | 137 &callback_); |
137 } else { | 138 } else { |
138 rv = cache_helper_.GetEntryInfoHTML(cache_key, request.context(), | 139 rv = cache_helper_.GetEntryInfoHTML(cache_key, request.context(), |
139 &data_, &callback_); | 140 &data_, &callback_); |
140 } | 141 } |
141 | 142 |
142 if (rv == net::ERR_IO_PENDING) | 143 if (rv == net::ERR_IO_PENDING) |
143 user_callback_ = callback; | 144 user_callback_ = callback; |
144 | 145 |
145 return rv; | 146 return rv; |
(...skipping 30 matching lines...) Expand all Loading... |
176 | 177 |
177 // We may be holding the last reference to this job. Do not access |this| | 178 // We may be holding the last reference to this job. Do not access |this| |
178 // after Release(). | 179 // after Release(). |
179 Release(); // Acquired on Start(). | 180 Release(); // Acquired on Start(). |
180 } | 181 } |
181 | 182 |
182 } // namespace. | 183 } // namespace. |
183 | 184 |
184 // Static. | 185 // Static. |
185 bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { | 186 bool ViewHttpCacheJobFactory::IsSupportedURL(const GURL& url) { |
186 return StartsWithASCII(url.spec(), chrome::kNetworkViewCacheURL, | 187 return url.SchemeIs(chrome::kChromeUIScheme) && |
187 true /*case_sensitive*/); | 188 url.host() == chrome::kChromeUINetworkViewCacheHost; |
188 } | 189 } |
189 | 190 |
190 // Static. | 191 // Static. |
191 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( | 192 net::URLRequestJob* ViewHttpCacheJobFactory::CreateJobForRequest( |
192 net::URLRequest* request) { | 193 net::URLRequest* request) { |
193 return new ViewHttpCacheJob(request); | 194 return new ViewHttpCacheJob(request); |
194 } | 195 } |
OLD | NEW |