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

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

Issue 8680015: base::Bind: Convert view_http_cache_job_factory.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
OLDNEW
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 15 matching lines...) Expand all
26 ViewCacheHelper(); 26 ViewCacheHelper();
27 ~ViewCacheHelper(); 27 ~ViewCacheHelper();
28 28
29 // Formats the cache information for |key| as HTML. Returns a net error code. 29 // Formats the cache information for |key| as HTML. Returns a net error code.
30 // If this method returns ERR_IO_PENDING, |callback| will be notified when the 30 // If this method returns ERR_IO_PENDING, |callback| will be notified when the
31 // operation completes. |out| must remain valid until this operation completes 31 // operation completes. |out| must remain valid until this operation completes
32 // or the object is destroyed. 32 // or the object is destroyed.
33 int GetEntryInfoHTML(const std::string& key, 33 int GetEntryInfoHTML(const std::string& key,
34 const URLRequestContext* context, 34 const URLRequestContext* context,
35 std::string* out, 35 std::string* out,
36 OldCompletionCallback* callback); 36 const CompletionCallback& callback);
37 37
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(const URLRequestContext* context, 43 int GetContentsHTML(const URLRequestContext* context,
44 const std::string& url_prefix, 44 const std::string& url_prefix,
45 std::string* out, 45 std::string* out,
46 OldCompletionCallback* callback); 46 const CompletionCallback& callback);
47 47
48 // Lower-level helper to produce a textual representation of binary data. 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 49 // The results are appended to |result| and can be used in HTML pages
50 // provided the dump is contained within <pre></pre> tags. 50 // provided the dump is contained within <pre></pre> tags.
51 static void HexDump(const char *buf, size_t buf_len, std::string* result); 51 static void HexDump(const char *buf, size_t buf_len, std::string* result);
52 52
53 private: 53 private:
54 enum State { 54 enum State {
55 STATE_NONE, 55 STATE_NONE,
56 STATE_GET_BACKEND, 56 STATE_GET_BACKEND,
57 STATE_GET_BACKEND_COMPLETE, 57 STATE_GET_BACKEND_COMPLETE,
58 STATE_OPEN_NEXT_ENTRY, 58 STATE_OPEN_NEXT_ENTRY,
59 STATE_OPEN_NEXT_ENTRY_COMPLETE, 59 STATE_OPEN_NEXT_ENTRY_COMPLETE,
60 STATE_OPEN_ENTRY, 60 STATE_OPEN_ENTRY,
61 STATE_OPEN_ENTRY_COMPLETE, 61 STATE_OPEN_ENTRY_COMPLETE,
62 STATE_READ_RESPONSE, 62 STATE_READ_RESPONSE,
63 STATE_READ_RESPONSE_COMPLETE, 63 STATE_READ_RESPONSE_COMPLETE,
64 STATE_READ_DATA, 64 STATE_READ_DATA,
65 STATE_READ_DATA_COMPLETE 65 STATE_READ_DATA_COMPLETE
66 }; 66 };
67 67
68 // Implements GetEntryInfoHTML and GetContentsHTML. 68 // Implements GetEntryInfoHTML and GetContentsHTML.
69 int GetInfoHTML(const std::string& key, 69 int GetInfoHTML(const std::string& key,
70 const URLRequestContext* context, 70 const URLRequestContext* context,
71 const std::string& url_prefix, 71 const std::string& url_prefix,
72 std::string* out, 72 std::string* out,
73 OldCompletionCallback* callback); 73 const CompletionCallback& callback);
74 74
75 // This is a helper function used to trigger a completion callback. It may 75 // This is a helper function used to trigger a completion callback. It may
76 // only be called if callback_ is non-null. 76 // only be called if callback_ is non-null.
77 void DoCallback(int rv); 77 void DoCallback(int rv);
78 78
79 // This will trigger the completion callback if appropriate. 79 // This will trigger the completion callback if appropriate.
80 void HandleResult(int rv); 80 void HandleResult(int rv);
81 81
82 // Runs the state transition loop. 82 // Runs the state transition loop.
83 int DoLoop(int result); 83 int DoLoop(int result);
(...skipping 19 matching lines...) Expand all
103 disk_cache::Backend* disk_cache_; 103 disk_cache::Backend* disk_cache_;
104 disk_cache::Entry* entry_; 104 disk_cache::Entry* entry_;
105 void* iter_; 105 void* iter_;
106 scoped_refptr<IOBuffer> buf_; 106 scoped_refptr<IOBuffer> buf_;
107 int buf_len_; 107 int buf_len_;
108 int index_; 108 int index_;
109 109
110 std::string key_; 110 std::string key_;
111 std::string url_prefix_; 111 std::string url_prefix_;
112 std::string* data_; 112 std::string* data_;
113 OldCompletionCallback* callback_; 113 CompletionCallback callback_;
114 114
115 State next_state_; 115 State next_state_;
116 116
117 OldCompletionCallbackImpl<ViewCacheHelper> cache_callback_; 117 OldCompletionCallbackImpl<ViewCacheHelper> cache_callback_;
118 scoped_refptr<CancelableOldCompletionCallback<ViewCacheHelper> > entry_callbac k_; 118 scoped_refptr<CancelableOldCompletionCallback<ViewCacheHelper> > entry_callbac k_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper); 120 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper);
121 }; 121 };
122 122
123 } // namespace net. 123 } // namespace net.
124 124
125 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ 125 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698