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

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

Issue 3390026: net: Append base:: in the StringPrintf calls. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix include order Created 10 years, 3 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 | « no previous file | net/base/cookie_monster_perftest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 #include <algorithm> 47 #include <algorithm>
48 48
49 #include "base/basictypes.h" 49 #include "base/basictypes.h"
50 #include "base/format_macros.h" 50 #include "base/format_macros.h"
51 #include "base/histogram.h" 51 #include "base/histogram.h"
52 #include "base/logging.h" 52 #include "base/logging.h"
53 #include "base/scoped_ptr.h" 53 #include "base/scoped_ptr.h"
54 #include "base/string_tokenizer.h" 54 #include "base/string_tokenizer.h"
55 #include "base/string_util.h" 55 #include "base/string_util.h"
56 #include "base/stringprintf.h"
56 #include "googleurl/src/gurl.h" 57 #include "googleurl/src/gurl.h"
57 #include "googleurl/src/url_canon.h" 58 #include "googleurl/src/url_canon.h"
58 #include "net/base/net_util.h" 59 #include "net/base/net_util.h"
59 #include "net/base/registry_controlled_domain.h" 60 #include "net/base/registry_controlled_domain.h"
60 61
61 // #define COOKIE_LOGGING_ENABLED 62 // #define COOKIE_LOGGING_ENABLED
62 #ifdef COOKIE_LOGGING_ENABLED 63 #ifdef COOKIE_LOGGING_ENABLED
63 #define COOKIE_DLOG(severity) DLOG_IF(INFO, 1) 64 #define COOKIE_DLOG(severity) DLOG_IF(INFO, 1)
64 #else 65 #else
65 #define COOKIE_DLOG(severity) DLOG_IF(INFO, 0) 66 #define COOKIE_DLOG(severity) DLOG_IF(INFO, 0)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // that way we don't have to worry about what sections of code are safe 210 // that way we don't have to worry about what sections of code are safe
210 // to call while it's in that state. 211 // to call while it's in that state.
211 std::set<int64> creation_times; 212 std::set<int64> creation_times;
212 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); 213 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
213 it != cookies.end(); ++it) { 214 it != cookies.end(); ++it) {
214 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue(); 215 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue();
215 216
216 if (creation_times.insert(cookie_creation_time).second) { 217 if (creation_times.insert(cookie_creation_time).second) {
217 InternalInsertCookie(GetKey((*it)->Domain()), *it, false); 218 InternalInsertCookie(GetKey((*it)->Domain()), *it, false);
218 } else { 219 } else {
219 LOG(ERROR) << StringPrintf("Found cookies with duplicate creation " 220 LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation "
220 "times in backing store: " 221 "times in backing store: "
221 "{name='%s', domain='%s', path='%s'}", 222 "{name='%s', domain='%s', path='%s'}",
222 (*it)->Name().c_str(), 223 (*it)->Name().c_str(),
223 (*it)->Domain().c_str(), 224 (*it)->Domain().c_str(),
224 (*it)->Path().c_str()); 225 (*it)->Path().c_str());
225 // We've been given ownership of the cookie and are throwing it 226 // We've been given ownership of the cookie and are throwing it
226 // away; reclaim the space. 227 // away; reclaim the space.
227 delete (*it); 228 delete (*it);
228 } 229 }
229 } 230 }
230 231
231 // After importing cookies from the PersistentCookieStore, verify that 232 // After importing cookies from the PersistentCookieStore, verify that
232 // none of our other constraints are violated. 233 // none of our other constraints are violated.
233 // 234 //
234 // In particular, the backing store might have given us duplicate cookies. 235 // In particular, the backing store might have given us duplicate cookies.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 CookieSet& dupes = it->second; 353 CookieSet& dupes = it->second;
353 354
354 if (dupes.size() <= 1) 355 if (dupes.size() <= 1)
355 continue; // This cookiename/path has no duplicates. 356 continue; // This cookiename/path has no duplicates.
356 num_duplicates_found += dupes.size() - 1; 357 num_duplicates_found += dupes.size() - 1;
357 358
358 // Since |dups| is sorted by creation time (descending), the first cookie 359 // Since |dups| is sorted by creation time (descending), the first cookie
359 // is the most recent one, so we will keep it. The rest are duplicates. 360 // is the most recent one, so we will keep it. The rest are duplicates.
360 dupes.erase(dupes.begin()); 361 dupes.erase(dupes.begin());
361 362
362 LOG(ERROR) << StringPrintf("Found %d duplicate cookies for host='%s', " 363 LOG(ERROR) << base::StringPrintf(
363 "with {name='%s', domain='%s', path='%s'}", 364 "Found %d duplicate cookies for host='%s', "
364 static_cast<int>(dupes.size()), 365 "with {name='%s', domain='%s', path='%s'}",
365 key.c_str(), 366 static_cast<int>(dupes.size()),
366 signature.name.c_str(), 367 key.c_str(),
367 signature.domain.c_str(), 368 signature.name.c_str(),
368 signature.path.c_str()); 369 signature.domain.c_str(),
370 signature.path.c_str());
369 371
370 // Remove all the cookies identified by |dupes|. It is valid to delete our 372 // Remove all the cookies identified by |dupes|. It is valid to delete our
371 // list of iterators one at a time, since |cookies_| is a multimap (they 373 // list of iterators one at a time, since |cookies_| is a multimap (they
372 // don't invalidate existing iterators following deletion). 374 // don't invalidate existing iterators following deletion).
373 for (CookieSet::iterator dupes_it = dupes.begin(); 375 for (CookieSet::iterator dupes_it = dupes.begin();
374 dupes_it != dupes.end(); 376 dupes_it != dupes.end();
375 ++dupes_it) { 377 ++dupes_it) {
376 InternalDeleteCookie(*dupes_it, true /*sync_to_store*/, 378 InternalDeleteCookie(*dupes_it, true /*sync_to_store*/,
377 DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE); 379 DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE);
378 } 380 }
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 return true; 1878 return true;
1877 1879
1878 // A pure suffix of the host (ok since we know the domain already 1880 // A pure suffix of the host (ok since we know the domain already
1879 // starts with a ".") 1881 // starts with a ".")
1880 return (host.length() > domain_.length() && 1882 return (host.length() > domain_.length() &&
1881 host.compare(host.length() - domain_.length(), 1883 host.compare(host.length() - domain_.length(),
1882 domain_.length(), domain_) == 0); 1884 domain_.length(), domain_) == 0);
1883 } 1885 }
1884 1886
1885 std::string CookieMonster::CanonicalCookie::DebugString() const { 1887 std::string CookieMonster::CanonicalCookie::DebugString() const {
1886 return StringPrintf("name: %s value: %s domain: %s path: %s creation: %" 1888 return base::StringPrintf(
1887 PRId64, 1889 "name: %s value: %s domain: %s path: %s creation: %"
1888 name_.c_str(), value_.c_str(), 1890 PRId64,
1889 domain_.c_str(), path_.c_str(), 1891 name_.c_str(), value_.c_str(),
1890 static_cast<int64>(creation_date_.ToTimeT())); 1892 domain_.c_str(), path_.c_str(),
1893 static_cast<int64>(creation_date_.ToTimeT()));
1891 } 1894 }
1892 1895
1893 } // namespace 1896 } // namespace
1894 1897
OLDNEW
« no previous file with comments | « no previous file | net/base/cookie_monster_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698