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

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

Issue 894903004: Adding instrumentation to locate the source of jankiness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 // 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 #include "base/basictypes.h" 51 #include "base/basictypes.h"
52 #include "base/bind.h" 52 #include "base/bind.h"
53 #include "base/callback.h" 53 #include "base/callback.h"
54 #include "base/logging.h" 54 #include "base/logging.h"
55 #include "base/memory/scoped_ptr.h" 55 #include "base/memory/scoped_ptr.h"
56 #include "base/memory/scoped_vector.h" 56 #include "base/memory/scoped_vector.h"
57 #include "base/message_loop/message_loop.h" 57 #include "base/message_loop/message_loop.h"
58 #include "base/message_loop/message_loop_proxy.h" 58 #include "base/message_loop/message_loop_proxy.h"
59 #include "base/metrics/histogram.h" 59 #include "base/metrics/histogram.h"
60 #include "base/profiler/scoped_tracker.h"
60 #include "base/strings/string_util.h" 61 #include "base/strings/string_util.h"
61 #include "base/strings/stringprintf.h" 62 #include "base/strings/stringprintf.h"
62 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 63 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
63 #include "net/cookies/canonical_cookie.h" 64 #include "net/cookies/canonical_cookie.h"
64 #include "net/cookies/cookie_util.h" 65 #include "net/cookies/cookie_util.h"
65 #include "net/cookies/parsed_cookie.h" 66 #include "net/cookies/parsed_cookie.h"
66 67
67 using base::Time; 68 using base::Time;
68 using base::TimeDelta; 69 using base::TimeDelta;
69 using base::TimeTicks; 70 using base::TimeTicks;
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 void CookieMonster::OnKeyLoaded(const std::string& key, 1462 void CookieMonster::OnKeyLoaded(const std::string& key,
1462 const std::vector<CanonicalCookie*>& cookies) { 1463 const std::vector<CanonicalCookie*>& cookies) {
1463 // This function does its own separate locking. 1464 // This function does its own separate locking.
1464 StoreLoadedCookies(cookies); 1465 StoreLoadedCookies(cookies);
1465 1466
1466 std::deque<scoped_refptr<CookieMonsterTask> > tasks_pending_for_key; 1467 std::deque<scoped_refptr<CookieMonsterTask> > tasks_pending_for_key;
1467 1468
1468 // We need to do this repeatedly until no more tasks were added to the queue 1469 // We need to do this repeatedly until no more tasks were added to the queue
1469 // during the period where we release the lock. 1470 // during the period where we release the lock.
1470 while (true) { 1471 while (true) {
1472 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456373 is
1473 // fixed.
1474 tracked_objects::ScopedTracker tracking_profile1(
1475 FROM_HERE_WITH_EXPLICIT_FUNCTION("456373 CookieMonster::OnKeyLoaded1"));
1471 { 1476 {
1472 base::AutoLock autolock(lock_); 1477 base::AutoLock autolock(lock_);
1473 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > > 1478 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > >
1474 ::iterator it = tasks_pending_for_key_.find(key); 1479 ::iterator it = tasks_pending_for_key_.find(key);
1475 if (it == tasks_pending_for_key_.end()) { 1480 if (it == tasks_pending_for_key_.end()) {
1476 keys_loaded_.insert(key); 1481 keys_loaded_.insert(key);
1477 return; 1482 return;
1478 } 1483 }
1479 if (it->second.empty()) { 1484 if (it->second.empty()) {
1480 keys_loaded_.insert(key); 1485 keys_loaded_.insert(key);
1481 tasks_pending_for_key_.erase(it); 1486 tasks_pending_for_key_.erase(it);
1482 return; 1487 return;
1483 } 1488 }
1484 it->second.swap(tasks_pending_for_key); 1489 it->second.swap(tasks_pending_for_key);
1485 } 1490 }
1486 1491
1492 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456373 is
1493 // fixed.
1494 tracked_objects::ScopedTracker tracking_profile2(
1495 FROM_HERE_WITH_EXPLICIT_FUNCTION("456373 CookieMonster::OnKeyLoaded2"));
1487 while (!tasks_pending_for_key.empty()) { 1496 while (!tasks_pending_for_key.empty()) {
1488 scoped_refptr<CookieMonsterTask> task = tasks_pending_for_key.front(); 1497 scoped_refptr<CookieMonsterTask> task = tasks_pending_for_key.front();
1489 task->Run(); 1498 task->Run();
1490 tasks_pending_for_key.pop_front(); 1499 tasks_pending_for_key.pop_front();
1491 } 1500 }
1492 } 1501 }
1493 } 1502 }
1494 1503
1495 void CookieMonster::StoreLoadedCookies( 1504 void CookieMonster::StoreLoadedCookies(
1496 const std::vector<CanonicalCookie*>& cookies) { 1505 const std::vector<CanonicalCookie*>& cookies) {
1506 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456373 is fixed.
1507 tracked_objects::ScopedTracker tracking_profile(
1508 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1509 "456373 CookieMonster::StoreLoadedCookies"));
1497 // Initialize the store and sync in any saved persistent cookies. We don't 1510 // Initialize the store and sync in any saved persistent cookies. We don't
1498 // care if it's expired, insert it so it can be garbage collected, removed, 1511 // care if it's expired, insert it so it can be garbage collected, removed,
1499 // and sync'd. 1512 // and sync'd.
1500 base::AutoLock autolock(lock_); 1513 base::AutoLock autolock(lock_);
1501 1514
1502 CookieItVector cookies_with_control_chars; 1515 CookieItVector cookies_with_control_chars;
1503 1516
1504 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); 1517 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
1505 it != cookies.end(); ++it) { 1518 it != cookies.end(); ++it) {
1506 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue(); 1519 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue();
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 it != hook_map_.end(); ++it) { 2354 it != hook_map_.end(); ++it) {
2342 std::pair<GURL, std::string> key = it->first; 2355 std::pair<GURL, std::string> key = it->first;
2343 if (cookie.IncludeForRequestURL(key.first, opts) && 2356 if (cookie.IncludeForRequestURL(key.first, opts) &&
2344 cookie.Name() == key.second) { 2357 cookie.Name() == key.second) {
2345 it->second->Notify(cookie, removed); 2358 it->second->Notify(cookie, removed);
2346 } 2359 }
2347 } 2360 }
2348 } 2361 }
2349 2362
2350 } // namespace net 2363 } // namespace net
OLDNEW
« no previous file with comments | « content/browser/net/sqlite_persistent_cookie_store.cc ('k') | net/url_request/url_fetcher_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698