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

Side by Side Diff: net/base/sdch_manager.cc

Issue 20379: Improve modularity of recent SDCH dictionary load checkin... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/url_request/url_request_http_job.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/field_trial.h" 5 #include "base/field_trial.h"
6 #include "base/histogram.h" 6 #include "base/histogram.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sha2.h" 8 #include "base/sha2.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/base64.h" 10 #include "net/base/base64.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // TODO(jar): Remove this failsafe conservative hack which is more restrictive 165 // TODO(jar): Remove this failsafe conservative hack which is more restrictive
166 // than current SDCH spec when needed, and justified by security audit. 166 // than current SDCH spec when needed, and justified by security audit.
167 if (!referring_url.SchemeIs("http")) { 167 if (!referring_url.SchemeIs("http")) {
168 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP); 168 SdchErrorRecovery(DICTIONARY_SELECTED_FROM_NON_HTTP);
169 return false; 169 return false;
170 } 170 }
171 171
172 return true; 172 return true;
173 } 173 }
174 174
175 void SdchManager::FetchDictionary(const GURL& dictionary_url) { 175 void SdchManager::FetchDictionary(const GURL& request_url,
176 if (fetcher_.get()) 176 const GURL& dictionary_url) {
177 if (SdchManager::Global()->CanFetchDictionary(request_url, dictionary_url) &&
178 fetcher_.get())
177 fetcher_->Schedule(dictionary_url); 179 fetcher_->Schedule(dictionary_url);
178 } 180 }
179 181
180 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text, 182 bool SdchManager::AddSdchDictionary(const std::string& dictionary_text,
181 const GURL& dictionary_url) { 183 const GURL& dictionary_url) {
182 std::string client_hash; 184 std::string client_hash;
183 std::string server_hash; 185 std::string server_hash;
184 GenerateHash(dictionary_text, &client_hash, &server_hash); 186 GenerateHash(dictionary_text, &client_hash, &server_hash);
185 if (dictionaries_.find(server_hash) != dictionaries_.end()) { 187 if (dictionaries_.find(server_hash) != dictionaries_.end()) {
186 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED); 188 SdchErrorRecovery(DICTIONARY_ALREADY_LOADED);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 return false; 500 return false;
499 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; 501 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/';
500 } 502 }
501 503
502 // static 504 // static
503 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, 505 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl,
504 const std::string& restriction) { 506 const std::string& restriction) {
505 // TODO(jar): This is not precisely a domain match definition. 507 // TODO(jar): This is not precisely a domain match definition.
506 return gurl.DomainIs(restriction.data(), restriction.size()); 508 return gurl.DomainIs(restriction.data(), restriction.size());
507 } 509 }
OLDNEW
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698