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