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

Unified Diff: ios/web/webui/url_fetcher_block_adapter.mm

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.mm
diff --git a/ios/web/webui/url_fetcher_block_adapter.mm b/ios/web/webui/url_fetcher_block_adapter.mm
new file mode 100644
index 0000000000000000000000000000000000000000..373235fe3718ca1cca0b5ede5bf2375b4ac9c353
--- /dev/null
+++ b/ios/web/webui/url_fetcher_block_adapter.mm
@@ -0,0 +1,41 @@
+// 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.
+
+#include "ios/web/webui/url_fetcher_block_adapter.h"
+
+#include "base/logging.h"
+#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_request_context_getter.h"
+
+namespace web {
+
+URLFetcherBlockAdapter::URLFetcherBlockAdapter(
+ const GURL& url,
+ net::URLRequestContextGetter* request_context,
+ web::URLFetcherBlockAdapterCompletion completion_handler)
+ : url_(url),
+ request_context_(request_context),
+ completion_handler_([completion_handler copy]) {
+}
+
+URLFetcherBlockAdapter::~URLFetcherBlockAdapter() {
+}
+
+void URLFetcherBlockAdapter::Start() {
+ fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this));
+ fetcher_->SetRequestContext(request_context_);
+ fetcher_->Start();
+}
+
+void URLFetcherBlockAdapter::OnURLFetchComplete(const net::URLFetcher* source) {
+ std::string response;
+ if (!source->GetResponseAsString(&response)) {
+ DLOG(WARNING) << "String for resource URL not found" << source->GetURL();
+ }
+ NSData* data =
+ [NSData dataWithBytes:response.c_str() length:response.length()];
+ completion_handler_.get()(data, this);
+}
+
+} // namespace web

Powered by Google App Engine
This is Rietveld 408576698