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 #ifndef NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ | 5 #ifndef NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ |
6 #define NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ | 6 #define NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Formats the cache contents as HTML. Returns a net error code. | 38 // Formats the cache contents as HTML. Returns a net error code. |
39 // If this method returns ERR_IO_PENDING, |callback| will be notified when the | 39 // If this method returns ERR_IO_PENDING, |callback| will be notified when the |
40 // operation completes. |out| must remain valid until this operation completes | 40 // operation completes. |out| must remain valid until this operation completes |
41 // or the object is destroyed. |url_prefix| will be prepended to each entry | 41 // or the object is destroyed. |url_prefix| will be prepended to each entry |
42 // key as a link to the entry. | 42 // key as a link to the entry. |
43 int GetContentsHTML(URLRequestContext* context, | 43 int GetContentsHTML(URLRequestContext* context, |
44 const std::string& url_prefix, | 44 const std::string& url_prefix, |
45 std::string* out, | 45 std::string* out, |
46 CompletionCallback* callback); | 46 CompletionCallback* callback); |
47 | 47 |
| 48 // Lower-level helper to produce a textual representation of binary data. |
| 49 // The results are appended to |result| and can be used in HTML pages |
| 50 // provided the dump is contained within <pre></pre> tags. |
| 51 static void HexDump(const char *buf, size_t buf_len, std::string* result); |
| 52 |
48 private: | 53 private: |
49 enum State { | 54 enum State { |
50 STATE_NONE, | 55 STATE_NONE, |
51 STATE_GET_BACKEND, | 56 STATE_GET_BACKEND, |
52 STATE_GET_BACKEND_COMPLETE, | 57 STATE_GET_BACKEND_COMPLETE, |
53 STATE_OPEN_NEXT_ENTRY, | 58 STATE_OPEN_NEXT_ENTRY, |
54 STATE_OPEN_NEXT_ENTRY_COMPLETE, | 59 STATE_OPEN_NEXT_ENTRY_COMPLETE, |
55 STATE_OPEN_ENTRY, | 60 STATE_OPEN_ENTRY, |
56 STATE_OPEN_ENTRY_COMPLETE, | 61 STATE_OPEN_ENTRY_COMPLETE, |
57 STATE_READ_RESPONSE, | 62 STATE_READ_RESPONSE, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 116 |
112 CompletionCallbackImpl<ViewCacheHelper> cache_callback_; | 117 CompletionCallbackImpl<ViewCacheHelper> cache_callback_; |
113 scoped_refptr<CancelableCompletionCallback<ViewCacheHelper> > entry_callback_; | 118 scoped_refptr<CancelableCompletionCallback<ViewCacheHelper> > entry_callback_; |
114 | 119 |
115 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper); | 120 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper); |
116 }; | 121 }; |
117 | 122 |
118 } // namespace net. | 123 } // namespace net. |
119 | 124 |
120 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ | 125 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ |
OLD | NEW |