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

Side by Side Diff: chrome/browser/chromeos/login/mock_url_fetchers.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 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
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 CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "content/common/net/url_fetcher.h" 14 #include "content/common/net/url_fetcher.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 17
18 namespace content {
19 class URLFetcherDelegate;
20 }
21
18 namespace chromeos { 22 namespace chromeos {
19 23
20 // Simulates a URL fetch by posting a delayed task. This fetch expects to be 24 // Simulates a URL fetch by posting a delayed task. This fetch expects to be
21 // canceled, and fails the test if it is not 25 // canceled, and fails the test if it is not
22 class ExpectCanceledFetcher : public URLFetcher { 26 class ExpectCanceledFetcher : public URLFetcher {
23 public: 27 public:
24 ExpectCanceledFetcher(bool success, 28 ExpectCanceledFetcher(bool success,
25 const GURL& url, 29 const GURL& url,
26 const std::string& results, 30 const std::string& results,
27 URLFetcher::RequestType request_type, 31 URLFetcher::RequestType request_type,
28 URLFetcher::Delegate* d); 32 content::URLFetcherDelegate* d);
29 virtual ~ExpectCanceledFetcher(); 33 virtual ~ExpectCanceledFetcher();
30 34
31 virtual void Start(); 35 virtual void Start();
32 36
33 void CompleteFetch(); 37 void CompleteFetch();
34 38
35 private: 39 private:
36 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_; 40 base::WeakPtrFactory<ExpectCanceledFetcher> weak_factory_;
37 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher); 41 DISALLOW_COPY_AND_ASSIGN(ExpectCanceledFetcher);
38 }; 42 };
39 43
40 class GotCanceledFetcher : public URLFetcher { 44 class GotCanceledFetcher : public URLFetcher {
41 public: 45 public:
42 GotCanceledFetcher(bool success, 46 GotCanceledFetcher(bool success,
43 const GURL& url, 47 const GURL& url,
44 const std::string& results, 48 const std::string& results,
45 URLFetcher::RequestType request_type, 49 URLFetcher::RequestType request_type,
46 URLFetcher::Delegate* d); 50 content::URLFetcherDelegate* d);
47 virtual ~GotCanceledFetcher(); 51 virtual ~GotCanceledFetcher();
48 52
49 virtual void Start(); 53 virtual void Start();
50 54
55 virtual const GURL& url() const;
56 virtual const net::URLRequestStatus& status() const;
57 virtual int response_code() const;
58
51 private: 59 private:
52 GURL url_; 60 GURL url_;
61 net::URLRequestStatus status_;
53 62
54 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher); 63 DISALLOW_COPY_AND_ASSIGN(GotCanceledFetcher);
55 }; 64 };
56 65
57 class SuccessFetcher : public URLFetcher { 66 class SuccessFetcher : public URLFetcher {
58 public: 67 public:
59 SuccessFetcher(bool success, 68 SuccessFetcher(bool success,
60 const GURL& url, 69 const GURL& url,
61 const std::string& results, 70 const std::string& results,
62 URLFetcher::RequestType request_type, 71 URLFetcher::RequestType request_type,
63 URLFetcher::Delegate* d); 72 content::URLFetcherDelegate* d);
64 virtual ~SuccessFetcher(); 73 virtual ~SuccessFetcher();
65 74
66 virtual void Start(); 75 virtual void Start();
67 76
77 virtual const GURL& url() const;
78 virtual const net::URLRequestStatus& status() const;
79 virtual int response_code() const;
80
68 private: 81 private:
69 GURL url_; 82 GURL url_;
83 net::URLRequestStatus status_;
70 84
71 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher); 85 DISALLOW_COPY_AND_ASSIGN(SuccessFetcher);
72 }; 86 };
73 87
74 class FailFetcher : public URLFetcher { 88 class FailFetcher : public URLFetcher {
75 public: 89 public:
76 FailFetcher(bool success, 90 FailFetcher(bool success,
77 const GURL& url, 91 const GURL& url,
78 const std::string& results, 92 const std::string& results,
79 URLFetcher::RequestType request_type, 93 URLFetcher::RequestType request_type,
80 URLFetcher::Delegate* d); 94 content::URLFetcherDelegate* d);
81 virtual ~FailFetcher(); 95 virtual ~FailFetcher();
82 96
83 virtual void Start(); 97 virtual void Start();
84 98
99 virtual const GURL& url() const;
100 virtual const net::URLRequestStatus& status() const;
101 virtual int response_code() const;
102
85 private: 103 private:
86 GURL url_; 104 GURL url_;
105 net::URLRequestStatus status_;
87 106
88 DISALLOW_COPY_AND_ASSIGN(FailFetcher); 107 DISALLOW_COPY_AND_ASSIGN(FailFetcher);
89 }; 108 };
90 109
91 class CaptchaFetcher : public URLFetcher { 110 class CaptchaFetcher : public URLFetcher {
92 public: 111 public:
93 CaptchaFetcher(bool success, 112 CaptchaFetcher(bool success,
94 const GURL& url, 113 const GURL& url,
95 const std::string& results, 114 const std::string& results,
96 URLFetcher::RequestType request_type, 115 URLFetcher::RequestType request_type,
97 URLFetcher::Delegate* d); 116 content::URLFetcherDelegate* d);
98 virtual ~CaptchaFetcher(); 117 virtual ~CaptchaFetcher();
99 118
100 static std::string GetCaptchaToken(); 119 static std::string GetCaptchaToken();
101 static std::string GetCaptchaUrl(); 120 static std::string GetCaptchaUrl();
102 static std::string GetUnlockUrl(); 121 static std::string GetUnlockUrl();
103 122
104 virtual void Start(); 123 virtual void Start();
105 124
125 virtual const GURL& url() const;
126 virtual const net::URLRequestStatus& status() const;
127 virtual int response_code() const;
128 virtual bool GetResponseAsString(std::string* out_response_string) const;
129
106 private: 130 private:
107 static const char kCaptchaToken[]; 131 static const char kCaptchaToken[];
108 static const char kCaptchaUrlBase[]; 132 static const char kCaptchaUrlBase[];
109 static const char kCaptchaUrlFragment[]; 133 static const char kCaptchaUrlFragment[];
110 static const char kUnlockUrl[]; 134 static const char kUnlockUrl[];
111 GURL url_; 135 GURL url_;
136 net::URLRequestStatus status_;
137 std::string data_;
112 138
113 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher); 139 DISALLOW_COPY_AND_ASSIGN(CaptchaFetcher);
114 }; 140 };
115 141
116 class HostedFetcher : public URLFetcher { 142 class HostedFetcher : public URLFetcher {
117 public: 143 public:
118 HostedFetcher(bool success, 144 HostedFetcher(bool success,
119 const GURL& url, 145 const GURL& url,
120 const std::string& results, 146 const std::string& results,
121 URLFetcher::RequestType request_type, 147 URLFetcher::RequestType request_type,
122 URLFetcher::Delegate* d); 148 content::URLFetcherDelegate* d);
123 virtual ~HostedFetcher(); 149 virtual ~HostedFetcher();
124 150
125 virtual void Start(); 151 virtual void Start();
126 152
153 virtual const GURL& url() const;
154 virtual const net::URLRequestStatus& status() const;
155 virtual int response_code() const;
156 virtual bool GetResponseAsString(std::string* out_response_string) const;
157
127 private: 158 private:
128 GURL url_; 159 GURL url_;
160 net::URLRequestStatus status_;
161 int response_code_;
162 std::string data_;
129 163
130 DISALLOW_COPY_AND_ASSIGN(HostedFetcher); 164 DISALLOW_COPY_AND_ASSIGN(HostedFetcher);
131 }; 165 };
132 166
133 } // namespace chromeos 167 } // namespace chromeos
134 168
135 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_ 169 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_URL_FETCHERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698