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

Unified Diff: ios/chrome/app/startup/network_stack_setup.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « ios/chrome/app/startup/network_stack_setup.h ('k') | ios/chrome/app/startup/provider_registration.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/app/startup/network_stack_setup.mm
diff --git a/ios/chrome/app/startup/network_stack_setup.mm b/ios/chrome/app/startup/network_stack_setup.mm
new file mode 100644
index 0000000000000000000000000000000000000000..533edeea8e2378ebed09fde6ef1de161c70c8e41
--- /dev/null
+++ b/ios/chrome/app/startup/network_stack_setup.mm
@@ -0,0 +1,45 @@
+// Copyright 2016 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/chrome/app/startup/network_stack_setup.h"
+
+#include "base/memory/ptr_util.h"
+#include "ios/chrome/browser/application_context.h"
+#include "ios/chrome/browser/chrome_url_constants.h"
+#import "ios/net/empty_nsurlcache.h"
+#include "ios/web/net/request_tracker_factory_impl.h"
+#include "ios/web/net/web_http_protocol_handler_delegate.h"
+
+@implementation NetworkStackSetup
+
++ (void)setUpChromeNetworkStack:
+ (std::unique_ptr<web::RequestTrackerFactoryImpl>*)
+ requestTrackerFactory
+ httpProtocolHandlerDelegate:
+ (std::unique_ptr<web::WebHTTPProtocolHandlerDelegate>*)
+ httpProtocolHandlerDelegate {
+ // Disable the default cache.
+ [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]];
+
+ // Configuration for the HTTP protocol handler.
+ // TODO(crbug.com/585700): Remove this code.
+ *httpProtocolHandlerDelegate =
+ base::MakeUnique<web::WebHTTPProtocolHandlerDelegate>(
+ GetApplicationContext()->GetSystemURLRequestContext());
+ net::HTTPProtocolHandlerDelegate::SetInstance(
+ httpProtocolHandlerDelegate->get());
+
+ // Register the chrome http protocol handler to replace the default one.
+ // TODO(crbug.com/665036): Move the network stack initialization to the web
+ // layer.
+ BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]];
+ DCHECK(success);
+ *requestTrackerFactory =
+ base::MakeUnique<web::RequestTrackerFactoryImpl>(kChromeUIScheme);
+ net::RequestTracker::SetRequestTrackerFactory(requestTrackerFactory->get());
+
+ DCHECK(success);
+}
+
+@end
« no previous file with comments | « ios/chrome/app/startup/network_stack_setup.h ('k') | ios/chrome/app/startup/provider_registration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698