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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 1818603002: Keep track of ChannelIDService in CookieStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DCHECKs, add comments to LogChannelIDAndCookieStores Created 4 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 | « net/url_request/url_request_context_builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; 59 static const char kAvailDictionaryHeader[] = "Avail-Dictionary";
60 60
61 namespace { 61 namespace {
62 62
63 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). 63 // True if the request method is "safe" (per section 4.2.1 of RFC 7231).
64 bool IsMethodSafe(const std::string& method) { 64 bool IsMethodSafe(const std::string& method) {
65 return method == "GET" || method == "HEAD" || method == "OPTIONS" || 65 return method == "GET" || method == "HEAD" || method == "OPTIONS" ||
66 method == "TRACE"; 66 method == "TRACE";
67 } 67 }
68 68
69 // Logs whether the CookieStore used for this request matches the
70 // ChannelIDService used when establishing the connection that this request is
71 // sent over. This logging is only done for requests to accounts.google.com, and
72 // only for requests where Channel ID was sent when establishing the connection.
69 void LogChannelIDAndCookieStores(const GURL& url, 73 void LogChannelIDAndCookieStores(const GURL& url,
70 const net::URLRequestContext* context, 74 const net::URLRequestContext* context,
71 const net::SSLInfo& ssl_info) { 75 const net::SSLInfo& ssl_info) {
72 if (url.host() != "accounts.google.com" || !ssl_info.channel_id_sent) 76 if (url.host() != "accounts.google.com" || !ssl_info.channel_id_sent)
73 return; 77 return;
74 // This enum is used for an UMA histogram - don't reuse or renumber entries. 78 // This enum is used for an UMA histogram - don't reuse or renumber entries.
75 enum { 79 enum {
76 // Value 0 was removed (CID_EPHEMERAL_COOKIE_EPHEMERAL) 80 // Value 0 was removed (CID_EPHEMERAL_COOKIE_EPHEMERAL)
81 // ChannelIDStore is ephemeral, but CookieStore is persistent.
77 CID_EPHEMERAL_COOKIE_PERSISTENT = 1, 82 CID_EPHEMERAL_COOKIE_PERSISTENT = 1,
83 // ChannelIDStore is persistent, but CookieStore is ephemeral.
78 CID_PERSISTENT_COOKIE_EPHEMERAL = 2, 84 CID_PERSISTENT_COOKIE_EPHEMERAL = 2,
79 // Value 3 was removed (CID_PERSISTENT_COOKIE_PERSISTENT) 85 // Value 3 was removed (CID_PERSISTENT_COOKIE_PERSISTENT)
86 // There is no CookieStore for this request.
80 NO_COOKIE_STORE = 4, 87 NO_COOKIE_STORE = 4,
88 // There is no ChannelIDStore for this request. This should never happen,
89 // because we only log if Channel ID was sent.
81 NO_CHANNEL_ID_STORE = 5, 90 NO_CHANNEL_ID_STORE = 5,
91 // A case where the CookieStore is persistent and the ChannelIDStore is
92 // ephemeral, but it has been identified as not being a problem.
82 KNOWN_MISMATCH = 6, 93 KNOWN_MISMATCH = 6,
94 // Both stores are ephemeral, and the ChannelIDService used when
95 // establishing the connection is the same one that the CookieStore was
96 // created to be used with.
83 EPHEMERAL_MATCH = 7, 97 EPHEMERAL_MATCH = 7,
98 // Both stores are ephemeral, but a different CookieStore should have been
99 // used on this request.
84 EPHEMERAL_MISMATCH = 8, 100 EPHEMERAL_MISMATCH = 8,
101 // Both stores are persistent, and the ChannelIDService used when
102 // establishing the connection is the same one that the CookieStore was
103 // created to be used with.
85 PERSISTENT_MATCH = 9, 104 PERSISTENT_MATCH = 9,
105 // Both stores are persistent, but a different CookieStore should have been
106 // used on this request.
86 PERSISTENT_MISMATCH = 10, 107 PERSISTENT_MISMATCH = 10,
108 // Both stores are ephemeral, but it was never recorded in the CookieStore
109 // which ChannelIDService it was created for, so it is unknown whether the
110 // stores match.
111 EPHEMERAL_UNKNOWN = 11,
112 // Both stores are persistent, but it was never recorded in the CookieStore
113 // which ChannelIDService it was created for, so it is unknown whether the
114 // stores match.
115 PERSISTENT_UNKNOWN = 12,
87 EPHEMERALITY_MAX 116 EPHEMERALITY_MAX
88 } ephemerality; 117 } ephemerality;
89 const net::HttpNetworkSession::Params* params = 118 const net::HttpNetworkSession::Params* params =
90 context->GetNetworkSessionParams(); 119 context->GetNetworkSessionParams();
91 net::CookieStore* cookie_store = context->cookie_store(); 120 net::CookieStore* cookie_store = context->cookie_store();
92 if (params == nullptr || params->channel_id_service == nullptr) { 121 if (params == nullptr || params->channel_id_service == nullptr) {
93 ephemerality = NO_CHANNEL_ID_STORE; 122 ephemerality = NO_CHANNEL_ID_STORE;
94 } else if (cookie_store == nullptr) { 123 } else if (cookie_store == nullptr) {
95 ephemerality = NO_COOKIE_STORE; 124 ephemerality = NO_COOKIE_STORE;
96 } else if (params->channel_id_service->GetChannelIDStore()->IsEphemeral()) { 125 } else if (params->channel_id_service->GetChannelIDStore()->IsEphemeral()) {
97 if (cookie_store->IsEphemeral()) { 126 if (cookie_store->IsEphemeral()) {
98 if (context->channel_id_service() && 127 if (cookie_store->GetChannelIDServiceID() == -1) {
99 params->channel_id_service->GetUniqueID() == 128 ephemerality = EPHEMERAL_UNKNOWN;
100 context->channel_id_service()->GetUniqueID()) { 129 } else if (cookie_store->GetChannelIDServiceID() ==
130 params->channel_id_service->GetUniqueID()) {
101 ephemerality = EPHEMERAL_MATCH; 131 ephemerality = EPHEMERAL_MATCH;
102 } else { 132 } else {
133 DCHECK(false);
mmenke 2016/03/29 20:14:25 nit: These should all be NOTREACHED()
103 ephemerality = EPHEMERAL_MISMATCH; 134 ephemerality = EPHEMERAL_MISMATCH;
104 } 135 }
105 } else if (context->has_known_mismatched_cookie_store()) { 136 } else if (context->has_known_mismatched_cookie_store()) {
106 ephemerality = KNOWN_MISMATCH; 137 ephemerality = KNOWN_MISMATCH;
107 } else { 138 } else {
139 DCHECK(false);
108 ephemerality = CID_EPHEMERAL_COOKIE_PERSISTENT; 140 ephemerality = CID_EPHEMERAL_COOKIE_PERSISTENT;
109 } 141 }
110 } else if (cookie_store->IsEphemeral()) { 142 } else if (cookie_store->IsEphemeral()) {
143 DCHECK(false);
111 ephemerality = CID_PERSISTENT_COOKIE_EPHEMERAL; 144 ephemerality = CID_PERSISTENT_COOKIE_EPHEMERAL;
112 } else if (context->channel_id_service() && 145 } else if (cookie_store->GetChannelIDServiceID() == -1) {
113 params->channel_id_service->GetUniqueID() == 146 ephemerality = PERSISTENT_UNKNOWN;
114 context->channel_id_service()->GetUniqueID()) { 147 } else if (cookie_store->GetChannelIDServiceID() ==
148 params->channel_id_service->GetUniqueID()) {
115 ephemerality = PERSISTENT_MATCH; 149 ephemerality = PERSISTENT_MATCH;
116 } else { 150 } else {
151 DCHECK(false);
117 ephemerality = PERSISTENT_MISMATCH; 152 ephemerality = PERSISTENT_MISMATCH;
118 } 153 }
119 UMA_HISTOGRAM_ENUMERATION("Net.TokenBinding.StoreEphemerality", ephemerality, 154 UMA_HISTOGRAM_ENUMERATION("Net.TokenBinding.StoreEphemerality", ephemerality,
120 EPHEMERALITY_MAX); 155 EPHEMERALITY_MAX);
121 } 156 }
122 157
123 } // namespace 158 } // namespace
124 159
125 namespace net { 160 namespace net {
126 161
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 return override_response_headers_.get() ? 1657 return override_response_headers_.get() ?
1623 override_response_headers_.get() : 1658 override_response_headers_.get() :
1624 transaction_->GetResponseInfo()->headers.get(); 1659 transaction_->GetResponseInfo()->headers.get();
1625 } 1660 }
1626 1661
1627 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1662 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1628 awaiting_callback_ = false; 1663 awaiting_callback_ = false;
1629 } 1664 }
1630 1665
1631 } // namespace net 1666 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698