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

Side by Side Diff: ios/web/webui/url_fetcher_block_adapter.h

Issue 1110213002: Upstream most of the iOS WebUI support in ios/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
(Empty)
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.
4
5 #ifndef IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
6 #define IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
7
8 #import <Foundation/Foundation.h>
9
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"
14
15 namespace net {
16 class URLFetcher;
17 class URLRequestContextGetter;
18 } // namespace net
19
20 namespace web {
21
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*);
27
28 // Class to manage retrieval of WebUI resources.
29 class URLFetcherBlockAdapter : public net::URLFetcherDelegate {
30 public:
31 // Create URLFetcherBlockAdapter for resource at |url| with |request_context|.
32 // |completion_handler| is called with results of the fetch.
33 URLFetcherBlockAdapter(
34 const GURL& url,
35 net::URLRequestContextGetter* request_context,
36 web::URLFetcherBlockAdapterCompletion completion_handler);
37 ~URLFetcherBlockAdapter() override;
38 // Start the fetch.
39 void Start();
40
41 protected:
42 // net::URLFetcherDelegate implementation.
43 void OnURLFetchComplete(const net::URLFetcher* source) override;
44
45 private:
46 // The URL to fetch.
47 const GURL url_;
48 // The request context.
49 net::URLRequestContextGetter* request_context_;
50 // Callback for resource load.
51 base::mac::ScopedBlock<web::URLFetcherBlockAdapterCompletion>
52 completion_handler_;
53 // URLFetcher for retrieving data from net stack.
54 scoped_ptr<net::URLFetcher> fetcher_;
55 };
56
57 } // namespace web
58
59 #endif // IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698