Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / third_party / libaddressinput / src / cpp / include / libaddressinput / downloader.h
1 // Copyright (C) 2013 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // The interface to be implemented by the user of the library to enable
16 // downloading validation rules from a server.
17
18 #ifndef I18N_ADDRESSINPUT_DOWNLOADER_H_
19 #define I18N_ADDRESSINPUT_DOWNLOADER_H_
20
21 #include <libaddressinput/callback.h>
22
23 #include <string>
24
25 namespace i18n {
26 namespace addressinput {
27
28 // Downloads validation rules from the server. The downloaded data must be
29 // allocated on the heap, passing ownership to the callback. Sample usage:
30 //
31 //    class MyDownloader : public Downloader {
32 //     public:
33 //      virtual void Download(const std::string& url,
34 //                            const Callback& downloaded) const {
35 //        bool success = ...
36 //        std::string* data = new ...
37 //        downloaded(success, url, data);
38 //      }
39 //    };
40 class Downloader {
41  public:
42   typedef i18n::addressinput::Callback<const std::string&,
43                                        std::string*> Callback;
44
45   virtual ~Downloader() {}
46
47   // Downloads |url| and invokes the |downloaded| callback.
48   virtual void Download(const std::string& url,
49                         const Callback& downloaded) const = 0;
50 };
51
52 }  // namespace addressinput
53 }  // namespace i18n
54
55 #endif  // I18N_ADDRESSINPUT_DOWNLOADER_H_