OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 "</table></body></html>" | 21 "</table></body></html>" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 void HexDump(const char *buf, size_t buf_len, std::string* result) { | 25 void HexDump(const char *buf, size_t buf_len, std::string* result) { |
26 const size_t kMaxRows = 16; | 26 const size_t kMaxRows = 16; |
27 int offset = 0; | 27 int offset = 0; |
28 | 28 |
29 const unsigned char *p; | 29 const unsigned char *p; |
30 while (buf_len) { | 30 while (buf_len) { |
31 StringAppendF(result, "%08x: ", offset); | 31 base::StringAppendF(result, "%08x: ", offset); |
32 offset += kMaxRows; | 32 offset += kMaxRows; |
33 | 33 |
34 p = (const unsigned char *) buf; | 34 p = (const unsigned char *) buf; |
35 | 35 |
36 size_t i; | 36 size_t i; |
37 size_t row_max = std::min(kMaxRows, buf_len); | 37 size_t row_max = std::min(kMaxRows, buf_len); |
38 | 38 |
39 // print hex codes: | 39 // print hex codes: |
40 for (i = 0; i < row_max; ++i) | 40 for (i = 0; i < row_max; ++i) |
41 StringAppendF(result, "%02x ", *p++); | 41 base::StringAppendF(result, "%02x ", *p++); |
42 for (i = row_max; i < kMaxRows; ++i) | 42 for (i = row_max; i < kMaxRows; ++i) |
43 result->append(" "); | 43 result->append(" "); |
44 | 44 |
45 // print ASCII glyphs if possible: | 45 // print ASCII glyphs if possible: |
46 p = (const unsigned char *) buf; | 46 p = (const unsigned char *) buf; |
47 for (i = 0; i < row_max; ++i, ++p) { | 47 for (i = 0; i < row_max; ++i, ++p) { |
48 if (*p < 0x7F && *p > 0x1F) { | 48 if (*p < 0x7F && *p > 0x1F) { |
49 AppendEscapedCharForHTML(*p, result); | 49 AppendEscapedCharForHTML(*p, result); |
50 } else { | 50 } else { |
51 result->push_back('.'); | 51 result->push_back('.'); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
OLD | NEW |