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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 #include "ios/web/net/request_tracker_factory_impl.h"
6
7 #include "base/logging.h"
8 #include "base/memory/weak_ptr.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "ios/web/net/request_group_util.h"
11 #include "ios/web/net/request_tracker_impl.h"
12
13 namespace web {
14
15 RequestTrackerFactoryImpl::RequestTrackerFactoryImpl(
16 const std::string& application_scheme) {
17 if (!application_scheme.empty()) {
18 application_scheme_.reset(
19 [base::SysUTF8ToNSString(application_scheme) copy]);
20 DCHECK(application_scheme_);
21 }
22 }
23
24 RequestTrackerFactoryImpl::~RequestTrackerFactoryImpl() {
25 }
26
27 bool RequestTrackerFactoryImpl::GetRequestTracker(
28 NSURLRequest* request,
29 base::WeakPtr<net::RequestTracker>* tracker) {
30 DCHECK(tracker);
31 DCHECK(!tracker->get());
32 NSString* request_group_id =
33 web::ExtractRequestGroupIDFromRequest(request, application_scheme_);
34 if (!request_group_id) {
35 // There was no request_group_id, so the request was from something like a
36 // data: or file: URL.
37 return true;
38 }
39 RequestTrackerImpl* tracker_impl =
40 RequestTrackerImpl::GetTrackerForRequestGroupID(request_group_id);
41 if (tracker_impl)
42 *tracker = tracker_impl->GetWeakPtr();
43 // If there is a request group ID, but no associated tracker, return false.
44 // This usually happens when the tab has been closed, but can maybe also
45 // happen in other cases (see http://crbug.com/228397).
46 return tracker->get() != nullptr;
47 }
48
49 } // namespace web
OLDNEW
« 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