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

Unified Diff: ios/web/net/request_tracker_factory_impl.mm

Issue 1043243003: Upstream most of ios/web/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove accidentally-added clients Created 5 years, 9 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
« no previous file with comments | « ios/web/net/request_tracker_factory_impl.h ('k') | ios/web/net/request_tracker_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/net/request_tracker_factory_impl.mm
diff --git a/ios/web/net/request_tracker_factory_impl.mm b/ios/web/net/request_tracker_factory_impl.mm
new file mode 100644
index 0000000000000000000000000000000000000000..8973d3c3a77fc6d0ed2f5743c9082fac4bef2e93
--- /dev/null
+++ b/ios/web/net/request_tracker_factory_impl.mm
@@ -0,0 +1,49 @@
+// Copyright 2014 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/net/request_tracker_factory_impl.h"
+
+#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
+#include "base/strings/sys_string_conversions.h"
+#include "ios/web/net/request_group_util.h"
+#include "ios/web/net/request_tracker_impl.h"
+
+namespace web {
+
+RequestTrackerFactoryImpl::RequestTrackerFactoryImpl(
+ const std::string& application_scheme) {
+ if (!application_scheme.empty()) {
+ application_scheme_.reset(
+ [base::SysUTF8ToNSString(application_scheme) copy]);
+ DCHECK(application_scheme_);
+ }
+}
+
+RequestTrackerFactoryImpl::~RequestTrackerFactoryImpl() {
+}
+
+bool RequestTrackerFactoryImpl::GetRequestTracker(
+ NSURLRequest* request,
+ base::WeakPtr<net::RequestTracker>* tracker) {
+ DCHECK(tracker);
+ DCHECK(!tracker->get());
+ NSString* request_group_id =
+ web::ExtractRequestGroupIDFromRequest(request, application_scheme_);
+ if (!request_group_id) {
+ // There was no request_group_id, so the request was from something like a
+ // data: or file: URL.
+ return true;
+ }
+ RequestTrackerImpl* tracker_impl =
+ RequestTrackerImpl::GetTrackerForRequestGroupID(request_group_id);
+ if (tracker_impl)
+ *tracker = tracker_impl->GetWeakPtr();
+ // If there is a request group ID, but no associated tracker, return false.
+ // This usually happens when the tab has been closed, but can maybe also
+ // happen in other cases (see http://crbug.com/228397).
+ return tracker->get() != nullptr;
+}
+
+} // namespace web
« no previous file with comments | « ios/web/net/request_tracker_factory_impl.h ('k') | ios/web/net/request_tracker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698