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

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

Issue 6056007: net: Add namespace net to the remaining files under url_request directory. (Closed)
Patch Set: chromeos fixes Created 9 years, 11 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
« no previous file with comments | « net/url_request/url_request_test_job.cc ('k') | net/websockets/websocket.h » ('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 #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
11 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 13
14 class URLRequestContext;
15
16 namespace disk_cache { 14 namespace disk_cache {
17 class Backend; 15 class Backend;
18 class Entry; 16 class Entry;
19 } 17 } // namespace disk_cache
20 18
21 namespace net { 19 namespace net {
22 20
21 class URLRequestContext;
22
23 class ViewCacheHelper { 23 class ViewCacheHelper {
24 public: 24 public:
25 ViewCacheHelper(); 25 ViewCacheHelper();
26 ~ViewCacheHelper(); 26 ~ViewCacheHelper();
27 27
28 // Formats the cache information for |key| as HTML. Returns a net error code. 28 // Formats the cache information for |key| as HTML. Returns a net error code.
29 // If this method returns ERR_IO_PENDING, |callback| will be notified when the 29 // If this method returns ERR_IO_PENDING, |callback| will be notified when the
30 // operation completes. |out| must remain valid until this operation completes 30 // operation completes. |out| must remain valid until this operation completes
31 // or the object is destroyed. 31 // or the object is destroyed.
32 int GetEntryInfoHTML(const std::string& key, URLRequestContext* context, 32 int GetEntryInfoHTML(const std::string& key,
33 std::string* out, CompletionCallback* callback); 33 net::URLRequestContext* context,
34 std::string* out,
35 CompletionCallback* callback);
34 36
35 // Formats the cache contents as HTML. Returns a net error code. 37 // Formats the cache contents as HTML. Returns a net error code.
36 // If this method returns ERR_IO_PENDING, |callback| will be notified when the 38 // If this method returns ERR_IO_PENDING, |callback| will be notified when the
37 // operation completes. |out| must remain valid until this operation completes 39 // operation completes. |out| must remain valid until this operation completes
38 // or the object is destroyed. |url_prefix| will be prepended to each entry 40 // or the object is destroyed. |url_prefix| will be prepended to each entry
39 // key as a link to the entry. 41 // key as a link to the entry.
40 int GetContentsHTML(URLRequestContext* context, const std::string& url_prefix, 42 int GetContentsHTML(net::URLRequestContext* context,
41 std::string* out, CompletionCallback* callback); 43 const std::string& url_prefix,
44 std::string* out,
45 CompletionCallback* callback);
42 46
43 private: 47 private:
44 enum State { 48 enum State {
45 STATE_NONE, 49 STATE_NONE,
46 STATE_GET_BACKEND, 50 STATE_GET_BACKEND,
47 STATE_GET_BACKEND_COMPLETE, 51 STATE_GET_BACKEND_COMPLETE,
48 STATE_OPEN_NEXT_ENTRY, 52 STATE_OPEN_NEXT_ENTRY,
49 STATE_OPEN_NEXT_ENTRY_COMPLETE, 53 STATE_OPEN_NEXT_ENTRY_COMPLETE,
50 STATE_OPEN_ENTRY, 54 STATE_OPEN_ENTRY,
51 STATE_OPEN_ENTRY_COMPLETE, 55 STATE_OPEN_ENTRY_COMPLETE,
52 STATE_READ_RESPONSE, 56 STATE_READ_RESPONSE,
53 STATE_READ_RESPONSE_COMPLETE, 57 STATE_READ_RESPONSE_COMPLETE,
54 STATE_READ_DATA, 58 STATE_READ_DATA,
55 STATE_READ_DATA_COMPLETE 59 STATE_READ_DATA_COMPLETE
56 }; 60 };
57 61
58 // Implements GetEntryInfoHTML and GetContentsHTML. 62 // Implements GetEntryInfoHTML and GetContentsHTML.
59 int GetInfoHTML(const std::string& key, URLRequestContext* context, 63 int GetInfoHTML(const std::string& key,
60 const std::string& url_prefix, std::string* out, 64 net::URLRequestContext* context,
65 const std::string& url_prefix,
66 std::string* out,
61 CompletionCallback* callback); 67 CompletionCallback* callback);
62 68
63 // This is a helper function used to trigger a completion callback. It may 69 // This is a helper function used to trigger a completion callback. It may
64 // only be called if callback_ is non-null. 70 // only be called if callback_ is non-null.
65 void DoCallback(int rv); 71 void DoCallback(int rv);
66 72
67 // This will trigger the completion callback if appropriate. 73 // This will trigger the completion callback if appropriate.
68 void HandleResult(int rv); 74 void HandleResult(int rv);
69 75
70 // Runs the state transition loop. 76 // Runs the state transition loop.
71 int DoLoop(int result); 77 int DoLoop(int result);
72 78
73 // Each of these methods corresponds to a State value. If there is an 79 // Each of these methods corresponds to a State value. If there is an
74 // argument, the value corresponds to the return of the previous state or 80 // argument, the value corresponds to the return of the previous state or
75 // corresponding callback. 81 // corresponding callback.
76 int DoGetBackend(); 82 int DoGetBackend();
77 int DoGetBackendComplete(int result); 83 int DoGetBackendComplete(int result);
78 int DoOpenNextEntry(); 84 int DoOpenNextEntry();
79 int DoOpenNextEntryComplete(int result); 85 int DoOpenNextEntryComplete(int result);
80 int DoOpenEntry(); 86 int DoOpenEntry();
81 int DoOpenEntryComplete(int result); 87 int DoOpenEntryComplete(int result);
82 int DoReadResponse(); 88 int DoReadResponse();
83 int DoReadResponseComplete(int result); 89 int DoReadResponseComplete(int result);
84 int DoReadData(); 90 int DoReadData();
85 int DoReadDataComplete(int result); 91 int DoReadDataComplete(int result);
86 92
87 // Called to signal completion of asynchronous IO. 93 // Called to signal completion of asynchronous IO.
88 void OnIOComplete(int result); 94 void OnIOComplete(int result);
89 95
90 scoped_refptr<URLRequestContext> context_; 96 scoped_refptr<net::URLRequestContext> context_;
91 disk_cache::Backend* disk_cache_; 97 disk_cache::Backend* disk_cache_;
92 disk_cache::Entry* entry_; 98 disk_cache::Entry* entry_;
93 void* iter_; 99 void* iter_;
94 scoped_refptr<net::IOBuffer> buf_; 100 scoped_refptr<net::IOBuffer> buf_;
95 int buf_len_; 101 int buf_len_;
96 int index_; 102 int index_;
97 103
98 std::string key_; 104 std::string key_;
99 std::string url_prefix_; 105 std::string url_prefix_;
100 std::string* data_; 106 std::string* data_;
101 CompletionCallback* callback_; 107 CompletionCallback* callback_;
102 108
103 State next_state_; 109 State next_state_;
104 110
105 CompletionCallbackImpl<ViewCacheHelper> cache_callback_; 111 CompletionCallbackImpl<ViewCacheHelper> cache_callback_;
106 scoped_refptr<CancelableCompletionCallback<ViewCacheHelper> > entry_callback_; 112 scoped_refptr<CancelableCompletionCallback<ViewCacheHelper> > entry_callback_;
107 113
108 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper); 114 DISALLOW_COPY_AND_ASSIGN(ViewCacheHelper);
109 }; 115 };
110 116
111 } // namespace net. 117 } // namespace net.
112 118
113 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_ 119 #endif // NET_URL_REQUEST_VIEW_CACHE_HELPER_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_job.cc ('k') | net/websockets/websocket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698