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

Side by Side Diff: chrome/browser/net/passive_log_collector.cc

Issue 6966038: Anti-DDoS enhancements: Log to net log, UMA stats, improved policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 9 years, 6 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 | « chrome/browser/net/passive_log_collector.h ('k') | chrome/common/net/gaia/gaia_oauth_client.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/net/passive_log_collector.h" 5 #include "chrome/browser/net/passive_log_collector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 //---------------------------------------------------------------------------- 48 //----------------------------------------------------------------------------
49 // PassiveLogCollector 49 // PassiveLogCollector
50 //---------------------------------------------------------------------------- 50 //----------------------------------------------------------------------------
51 51
52 PassiveLogCollector::PassiveLogCollector() 52 PassiveLogCollector::PassiveLogCollector()
53 : ThreadSafeObserver(net::NetLog::LOG_BASIC), 53 : ThreadSafeObserver(net::NetLog::LOG_BASIC),
54 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)), 54 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)),
55 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)), 55 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)),
56 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)), 56 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)),
57 ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_job_tracker_(this)), 57 ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_job_tracker_(this)),
58 ALLOW_THIS_IN_INITIALIZER_LIST(
59 exponential_backoff_throttling_tracker_(this)),
58 num_events_seen_(0) { 60 num_events_seen_(0) {
59 61
60 // Define the mapping between source types and the tracker objects. 62 // Define the mapping between source types and the tracker objects.
61 memset(&trackers_[0], 0, sizeof(trackers_)); 63 memset(&trackers_[0], 0, sizeof(trackers_));
62 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_; 64 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_;
63 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_; 65 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_;
64 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_; 66 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_;
65 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_; 67 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_;
66 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_; 68 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_;
67 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] = 69 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] =
68 &init_proxy_resolver_tracker_; 70 &init_proxy_resolver_tracker_;
69 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_; 71 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_;
70 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] = 72 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] =
71 &dns_request_tracker_; 73 &dns_request_tracker_;
72 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_; 74 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_;
73 trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_; 75 trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_;
74 trackers_[net::NetLog::SOURCE_MEMORY_CACHE_ENTRY] = &mem_cache_entry_tracker_; 76 trackers_[net::NetLog::SOURCE_MEMORY_CACHE_ENTRY] = &mem_cache_entry_tracker_;
75 trackers_[net::NetLog::SOURCE_HTTP_STREAM_JOB] = &http_stream_job_tracker_; 77 trackers_[net::NetLog::SOURCE_HTTP_STREAM_JOB] = &http_stream_job_tracker_;
78 trackers_[net::NetLog::SOURCE_EXPONENTIAL_BACKOFF_THROTTLING] =
79 &exponential_backoff_throttling_tracker_;
76 // Make sure our mapping is up-to-date. 80 // Make sure our mapping is up-to-date.
77 for (size_t i = 0; i < arraysize(trackers_); ++i) 81 for (size_t i = 0; i < arraysize(trackers_); ++i)
78 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i; 82 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i;
79 } 83 }
80 84
81 PassiveLogCollector::~PassiveLogCollector() { 85 PassiveLogCollector::~PassiveLogCollector() {
82 } 86 }
83 87
84 void PassiveLogCollector::OnAddEntry( 88 void PassiveLogCollector::OnAddEntry(
85 net::NetLog::EventType type, 89 net::NetLog::EventType type,
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 AddEntryToSourceInfo(entry, out_info); 641 AddEntryToSourceInfo(entry, out_info);
638 642
639 // If the request has ended, move it to the graveyard. 643 // If the request has ended, move it to the graveyard.
640 if (entry.type == net::NetLog::TYPE_HTTP_STREAM_JOB && 644 if (entry.type == net::NetLog::TYPE_HTTP_STREAM_JOB &&
641 entry.phase == net::NetLog::PHASE_END) { 645 entry.phase == net::NetLog::PHASE_END) {
642 return ACTION_MOVE_TO_GRAVEYARD; 646 return ACTION_MOVE_TO_GRAVEYARD;
643 } 647 }
644 648
645 return ACTION_NONE; 649 return ACTION_NONE;
646 } 650 }
651
652 //----------------------------------------------------------------------------
653 // ExponentialBackoffThrottlingTracker
654 //----------------------------------------------------------------------------
655
656 const size_t PassiveLogCollector::
657 ExponentialBackoffThrottlingTracker::kMaxNumSources = 100;
658 const size_t PassiveLogCollector::
659 ExponentialBackoffThrottlingTracker::kMaxGraveyardSize = 25;
660
661 PassiveLogCollector::
662 ExponentialBackoffThrottlingTracker::ExponentialBackoffThrottlingTracker(
663 PassiveLogCollector* parent)
664 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) {
665 }
666
667 PassiveLogCollector::SourceTracker::Action
668 PassiveLogCollector::ExponentialBackoffThrottlingTracker::DoAddEntry(
669 const ChromeNetLog::Entry& entry, SourceInfo* out_info) {
670 AddEntryToSourceInfo(entry, out_info);
671 return ACTION_NONE;
672 }
OLDNEW
« no previous file with comments | « chrome/browser/net/passive_log_collector.h ('k') | chrome/common/net/gaia/gaia_oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698