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

Side by Side Diff: net/url_request/view_cache_helper.cc

Issue 6730034: Remove all "net::" prefixes under net/url_request for code that's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed indentation Created 9 years, 9 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
« no previous file with comments | « net/url_request/view_cache_helper.h ('k') | net/url_request/view_cache_helper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 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 "net/url_request/view_cache_helper.h" 5 #include "net/url_request/view_cache_helper.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "net/base/escape.h" 8 #include "net/base/escape.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/disk_cache/disk_cache.h" 11 #include "net/disk_cache/disk_cache.h"
12 #include "net/http/http_cache.h" 12 #include "net/http/http_cache.h"
13 #include "net/http/http_response_headers.h" 13 #include "net/http/http_response_headers.h"
14 #include "net/http/http_response_info.h" 14 #include "net/http/http_response_info.h"
15 #include "net/url_request/url_request_context.h" 15 #include "net/url_request/url_request_context.h"
16 16
17 #define VIEW_CACHE_HEAD \ 17 #define VIEW_CACHE_HEAD \
18 "<html><body><table>" 18 "<html><body><table>"
19 19
20 #define VIEW_CACHE_TAIL \ 20 #define VIEW_CACHE_TAIL \
21 "</table></body></html>" 21 "</table></body></html>"
22 22
23 namespace net {
24
23 namespace { 25 namespace {
24 26
25 void HexDump(const char *buf, size_t buf_len, std::string* result) { 27 void HexDump(const char *buf, size_t buf_len, std::string* result) {
26 const size_t kMaxRows = 16; 28 const size_t kMaxRows = 16;
27 int offset = 0; 29 int offset = 0;
28 30
29 const unsigned char *p; 31 const unsigned char *p;
30 while (buf_len) { 32 while (buf_len) {
31 base::StringAppendF(result, "%08x: ", offset); 33 base::StringAppendF(result, "%08x: ", offset);
32 offset += kMaxRows; 34 offset += kMaxRows;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 std::string key = entry->GetKey(); 66 std::string key = entry->GetKey();
65 GURL url = GURL(url_prefix + key); 67 GURL url = GURL(url_prefix + key);
66 std::string row = 68 std::string row =
67 "<tr><td><a href=\"" + url.spec() + "\">" + EscapeForHTML(key) + 69 "<tr><td><a href=\"" + url.spec() + "\">" + EscapeForHTML(key) +
68 "</a></td></tr>"; 70 "</a></td></tr>";
69 return row; 71 return row;
70 } 72 }
71 73
72 } // namespace. 74 } // namespace.
73 75
74 namespace net {
75
76 ViewCacheHelper::ViewCacheHelper() 76 ViewCacheHelper::ViewCacheHelper()
77 : disk_cache_(NULL), 77 : disk_cache_(NULL),
78 entry_(NULL), 78 entry_(NULL),
79 iter_(NULL), 79 iter_(NULL),
80 buf_len_(0), 80 buf_len_(0),
81 index_(0), 81 index_(0),
82 data_(NULL), 82 data_(NULL),
83 callback_(NULL), 83 callback_(NULL),
84 next_state_(STATE_NONE), 84 next_state_(STATE_NONE),
85 ALLOW_THIS_IN_INITIALIZER_LIST( 85 ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 return rv; 207 return rv;
208 } 208 }
209 209
210 int ViewCacheHelper::DoGetBackend() { 210 int ViewCacheHelper::DoGetBackend() {
211 next_state_ = STATE_GET_BACKEND_COMPLETE; 211 next_state_ = STATE_GET_BACKEND_COMPLETE;
212 212
213 if (!context_->http_transaction_factory()) 213 if (!context_->http_transaction_factory())
214 return ERR_FAILED; 214 return ERR_FAILED;
215 215
216 net::HttpCache* http_cache = context_->http_transaction_factory()->GetCache(); 216 HttpCache* http_cache = context_->http_transaction_factory()->GetCache();
217 if (!http_cache) 217 if (!http_cache)
218 return ERR_FAILED; 218 return ERR_FAILED;
219 219
220 return http_cache->GetBackend(&disk_cache_, &cache_callback_); 220 return http_cache->GetBackend(&disk_cache_, &cache_callback_);
221 } 221 }
222 222
223 int ViewCacheHelper::DoGetBackendComplete(int result) { 223 int ViewCacheHelper::DoGetBackendComplete(int result) {
224 if (result == ERR_FAILED) { 224 if (result == ERR_FAILED) {
225 data_->append("no disk cache"); 225 data_->append("no disk cache");
226 return OK; 226 return OK;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return OK; 275 return OK;
276 } 276 }
277 277
278 int ViewCacheHelper::DoReadResponse() { 278 int ViewCacheHelper::DoReadResponse() {
279 next_state_ = STATE_READ_RESPONSE_COMPLETE; 279 next_state_ = STATE_READ_RESPONSE_COMPLETE;
280 buf_len_ = entry_->GetDataSize(0); 280 buf_len_ = entry_->GetDataSize(0);
281 entry_callback_->AddRef(); 281 entry_callback_->AddRef();
282 if (!buf_len_) 282 if (!buf_len_)
283 return buf_len_; 283 return buf_len_;
284 284
285 buf_ = new net::IOBuffer(buf_len_); 285 buf_ = new IOBuffer(buf_len_);
286 return entry_->ReadData(0, 0, buf_, buf_len_, entry_callback_); 286 return entry_->ReadData(0, 0, buf_, buf_len_, entry_callback_);
287 } 287 }
288 288
289 int ViewCacheHelper::DoReadResponseComplete(int result) { 289 int ViewCacheHelper::DoReadResponseComplete(int result) {
290 entry_callback_->Release(); 290 entry_callback_->Release();
291 if (result && result == buf_len_) { 291 if (result && result == buf_len_) {
292 net::HttpResponseInfo response; 292 HttpResponseInfo response;
293 bool truncated; 293 bool truncated;
294 if (net::HttpCache::ParseResponseInfo(buf_->data(), buf_len_, &response, 294 if (HttpCache::ParseResponseInfo(buf_->data(), buf_len_, &response,
295 &truncated) && 295 &truncated) &&
296 response.headers) { 296 response.headers) {
297 if (truncated) 297 if (truncated)
298 data_->append("<pre>RESPONSE_INFO_TRUNCATED</pre>"); 298 data_->append("<pre>RESPONSE_INFO_TRUNCATED</pre>");
299 299
300 data_->append("<hr><pre>"); 300 data_->append("<hr><pre>");
301 data_->append(EscapeForHTML(response.headers->GetStatusLine())); 301 data_->append(EscapeForHTML(response.headers->GetStatusLine()));
302 data_->push_back('\n'); 302 data_->push_back('\n');
303 303
304 void* iter = NULL; 304 void* iter = NULL;
(...skipping 15 matching lines...) Expand all
320 320
321 int ViewCacheHelper::DoReadData() { 321 int ViewCacheHelper::DoReadData() {
322 data_->append("<hr><pre>"); 322 data_->append("<hr><pre>");
323 323
324 next_state_ = STATE_READ_DATA_COMPLETE; 324 next_state_ = STATE_READ_DATA_COMPLETE;
325 buf_len_ = entry_->GetDataSize(index_); 325 buf_len_ = entry_->GetDataSize(index_);
326 entry_callback_->AddRef(); 326 entry_callback_->AddRef();
327 if (!buf_len_) 327 if (!buf_len_)
328 return buf_len_; 328 return buf_len_;
329 329
330 buf_ = new net::IOBuffer(buf_len_); 330 buf_ = new IOBuffer(buf_len_);
331 return entry_->ReadData(index_, 0, buf_, buf_len_, entry_callback_); 331 return entry_->ReadData(index_, 0, buf_, buf_len_, entry_callback_);
332 } 332 }
333 333
334 int ViewCacheHelper::DoReadDataComplete(int result) { 334 int ViewCacheHelper::DoReadDataComplete(int result) {
335 entry_callback_->Release(); 335 entry_callback_->Release();
336 if (result && result == buf_len_) { 336 if (result && result == buf_len_) {
337 HexDump(buf_->data(), buf_len_, data_); 337 HexDump(buf_->data(), buf_len_, data_);
338 } 338 }
339 data_->append("</pre>"); 339 data_->append("</pre>");
340 index_++; 340 index_++;
341 if (index_ < net::HttpCache::kNumCacheEntryDataIndices) { 341 if (index_ < HttpCache::kNumCacheEntryDataIndices) {
342 next_state_ = STATE_READ_DATA; 342 next_state_ = STATE_READ_DATA;
343 } else { 343 } else {
344 data_->append(VIEW_CACHE_TAIL); 344 data_->append(VIEW_CACHE_TAIL);
345 entry_->Close(); 345 entry_->Close();
346 entry_ = NULL; 346 entry_ = NULL;
347 } 347 }
348 return OK; 348 return OK;
349 } 349 }
350 350
351 void ViewCacheHelper::OnIOComplete(int result) { 351 void ViewCacheHelper::OnIOComplete(int result) {
352 DoLoop(result); 352 DoLoop(result);
353 } 353 }
354 354
355 } // namespace net. 355 } // namespace net.
OLDNEW
« no previous file with comments | « net/url_request/view_cache_helper.h ('k') | net/url_request/view_cache_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698