OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 class URLFetcher; | 24 class URLFetcher; |
25 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
26 } | 26 } |
27 | 27 |
28 namespace app_list { | 28 namespace app_list { |
29 | 29 |
30 // A class that fetches a JSON formatted response from a server and uses a | 30 // A class that fetches a JSON formatted response from a server and uses a |
31 // sandboxed utility process to parse it to a DictionaryValue. | 31 // sandboxed utility process to parse it to a DictionaryValue. |
| 32 // TODO(rkc): Add the ability to give control of handling http failures to |
| 33 // the consumers of this class. |
32 class JSONResponseFetcher : public net::URLFetcherDelegate { | 34 class JSONResponseFetcher : public net::URLFetcherDelegate { |
33 public: | 35 public: |
34 // Callback to pass back the parsed json dictionary returned from the server. | 36 // Callback to pass back the parsed json dictionary returned from the server. |
35 // Invoked with NULL if there is an error. | 37 // Invoked with NULL if there is an error. |
36 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> Callback; | 38 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> Callback; |
37 | 39 |
38 JSONResponseFetcher(const Callback& callback, | 40 JSONResponseFetcher(const Callback& callback, |
39 net::URLRequestContextGetter* context_getter); | 41 net::URLRequestContextGetter* context_getter); |
40 virtual ~JSONResponseFetcher(); | 42 virtual ~JSONResponseFetcher(); |
41 | 43 |
(...skipping 14 matching lines...) Expand all Loading... |
56 | 58 |
57 scoped_ptr<net::URLFetcher> fetcher_; | 59 scoped_ptr<net::URLFetcher> fetcher_; |
58 base::WeakPtrFactory<JSONResponseFetcher> weak_factory_; | 60 base::WeakPtrFactory<JSONResponseFetcher> weak_factory_; |
59 | 61 |
60 DISALLOW_COPY_AND_ASSIGN(JSONResponseFetcher); | 62 DISALLOW_COPY_AND_ASSIGN(JSONResponseFetcher); |
61 }; | 63 }; |
62 | 64 |
63 } // namespace app_list | 65 } // namespace app_list |
64 | 66 |
65 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ | 67 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_JSON_RESPONSE_FETCHER_H_ |
OLD | NEW |