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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/webui/url_fetcher_block_adapter.h
diff --git a/ios/web/webui/url_fetcher_block_adapter.h b/ios/web/webui/url_fetcher_block_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..1e2f055d9a7b78d6bf79b3e40e49591c8f9fb9e8
--- /dev/null
+++ b/ios/web/webui/url_fetcher_block_adapter.h
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
+#define IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_
+
+#import <Foundation/Foundation.h>
+
+#include "base/mac/scoped_block.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_fetcher_delegate.h"
+#include "url/gurl.h"
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+} // namespace net
+
+namespace web {
+
+// Class for use of URLFetcher from Objective-C with a completion handler block.
+class URLFetcherBlockAdapter;
+// Block type for URLFetcherBlockAdapter callbacks.
+typedef void (^URLFetcherBlockAdapterCompletion)(NSData*,
+ URLFetcherBlockAdapter*);
+
+// Class to manage retrieval of WebUI resources.
+class URLFetcherBlockAdapter : public net::URLFetcherDelegate {
+ public:
+ // Create URLFetcherBlockAdapter for resource at |url| with |request_context|.
+ // |completion_handler| is called with results of the fetch.
+ URLFetcherBlockAdapter(
+ const GURL& url,
+ net::URLRequestContextGetter* request_context,
+ web::URLFetcherBlockAdapterCompletion completion_handler);
+ ~URLFetcherBlockAdapter() override;
+ // Start the fetch.
+ void Start();
+
+ protected:
+ // net::URLFetcherDelegate implementation.
+ void OnURLFetchComplete(const net::URLFetcher* source) override;
+
+ private:
+ // The URL to fetch.
+ const GURL url_;
+ // The request context.
+ net::URLRequestContextGetter* request_context_;
+ // Callback for resource load.
+ base::mac::ScopedBlock<web::URLFetcherBlockAdapterCompletion>
+ completion_handler_;
+ // URLFetcher for retrieving data from net stack.
+ scoped_ptr<net::URLFetcher> fetcher_;
+};
+
+} // namespace web
+
+#endif // IOS_WEB_WEBUI_URL_FETCHER_BLOCK_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698