OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/scoped_ptr.h" | |
12 #include "chrome/common/net/url_fetcher.h" | |
13 | |
14 // This class is used to fetch an URL and store result as a string. | |
15 class StringFetcher : public URLFetcher::Delegate { | |
16 public: | |
17 // Initiates URL fetch. | |
18 explicit StringFetcher(const std::string& url); | |
19 | |
20 const std::string& result() const { return result_; } | |
21 int response_code() const { return response_code_; } | |
22 bool succeeded() const { return response_code_ == 200; } | |
23 | |
24 private: | |
25 // Overriden from URLFetcher::Delegate: | |
26 virtual void OnURLFetchComplete(const URLFetcher* source, | |
27 const GURL& url, | |
28 const URLRequestStatus& status, | |
29 int response_code, | |
30 const ResponseCookies& cookies, | |
31 const std::string& data); | |
32 // Timer notification handler. | |
33 void OnTimeoutElapsed(); | |
34 | |
35 // URLFetcher instance. | |
36 scoped_ptr<URLFetcher> url_fetcher_; | |
37 | |
38 // Fetch result. | |
39 std::string result_; | |
40 | |
41 // Received HTTP response code. | |
42 int response_code_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(StringFetcher); | |
45 }; | |
46 | |
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_ | |
OLD | NEW |