Add ICU message format support
[chromium-blink-merge.git] / ios / web / webui / url_fetcher_block_adapter.h
blob095240b404dd253ae837b33680511df6f46eddda
1 // Copyright 2015 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.
5 #ifndef IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
6 #define IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
8 #import <Foundation/Foundation.h>
10 #include "base/mac/scoped_block.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "url/gurl.h"
15 namespace net {
16 class URLFetcher;
17 class URLRequestContextGetter;
18 } // namespace net
20 namespace web {
22 // Class for use of URLFetcher from Objective-C with a completion handler block.
23 class URLFetcherBlockAdapter;
24 // Block type for URLFetcherBlockAdapter callbacks.
25 typedef void (^URLFetcherBlockAdapterCompletion)(NSData*,
26 URLFetcherBlockAdapter*);
28 // Class to manage retrieval of WebUI resources.
29 class URLFetcherBlockAdapter : public net::URLFetcherDelegate {
30 public:
31 // Creates URLFetcherBlockAdapter for resource at |url| with
32 // |request_context|.
33 // |completion_handler| is called with results of the fetch.
34 URLFetcherBlockAdapter(
35 const GURL& url,
36 net::URLRequestContextGetter* request_context,
37 web::URLFetcherBlockAdapterCompletion completion_handler);
38 ~URLFetcherBlockAdapter() override;
39 // Starts the fetch.
40 virtual void Start();
42 protected:
43 // net::URLFetcherDelegate implementation.
44 void OnURLFetchComplete(const net::URLFetcher* source) override;
46 private:
47 // The URL to fetch.
48 const GURL url_;
49 // The request context.
50 net::URLRequestContextGetter* request_context_;
51 // Callback for resource load.
52 base::mac::ScopedBlock<web::URLFetcherBlockAdapterCompletion>
53 completion_handler_;
54 // URLFetcher for retrieving data from net stack.
55 scoped_ptr<net::URLFetcher> fetcher_;
58 } // namespace web
60 #endif // IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_