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

Side by Side Diff: net/url_request/url_request_throttler_manager.h

Issue 6696023: Remove minidump analysis aides from URLRequestThrottlerManager. New (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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
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 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_
7 #pragma once
7 8
8 #include <map> 9 #include <map>
9 #include <string> 10 #include <string>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
13 #include "base/singleton.h" 14 #include "base/singleton.h"
14 #include "base/threading/thread_checker_impl.h" 15 #include "base/threading/non_thread_safe.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #include "net/url_request/url_request_throttler_entry.h" 17 #include "net/url_request/url_request_throttler_entry.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 // Class that registers URL request throttler entries for URLs being accessed 21 // Class that registers URL request throttler entries for URLs being accessed
21 // in order to supervise traffic. URL requests for HTTP contents should 22 // in order to supervise traffic. URL requests for HTTP contents should
22 // register their URLs in this manager on each request. 23 // register their URLs in this manager on each request.
23 // 24 //
24 // URLRequestThrottlerManager maintains a map of URL IDs to URL request 25 // URLRequestThrottlerManager maintains a map of URL IDs to URL request
25 // throttler entries. It creates URL request throttler entries when new URLs 26 // throttler entries. It creates URL request throttler entries when new URLs
26 // are registered, and does garbage collection from time to time in order to 27 // are registered, and does garbage collection from time to time in order to
27 // clean out outdated entries. URL ID consists of lowercased scheme, host, port 28 // clean out outdated entries. URL ID consists of lowercased scheme, host, port
28 // and path. All URLs converted to the same ID will share the same entry. 29 // and path. All URLs converted to the same ID will share the same entry.
29 // 30 class URLRequestThrottlerManager : public base::NonThreadSafe {
30 // NOTE: All usage of the singleton object of this class should be on the same
31 // thread.
32 //
33 // TODO(joi): Switch back to NonThreadSafe (and remove checks in release builds)
34 // once crbug.com/71721 has been tracked down.
35 class URLRequestThrottlerManager {
36 public: 31 public:
37 static URLRequestThrottlerManager* GetInstance(); 32 static URLRequestThrottlerManager* GetInstance();
38 33
39 // Must be called for every request, returns the URL request throttler entry 34 // Must be called for every request, returns the URL request throttler entry
40 // associated with the URL. The caller must inform this entry of some events. 35 // associated with the URL. The caller must inform this entry of some events.
41 // Please refer to url_request_throttler_entry_interface.h for further 36 // Please refer to url_request_throttler_entry_interface.h for further
42 // informations. 37 // informations.
43 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( 38 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl(
44 const GURL& url); 39 const GURL& url);
45 40
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // From each URL we generate an ID composed of the scheme, host, port and path 81 // From each URL we generate an ID composed of the scheme, host, port and path
87 // that allows us to uniquely map an entry to it. 82 // that allows us to uniquely map an entry to it.
88 typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> > 83 typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> >
89 UrlEntryMap; 84 UrlEntryMap;
90 85
91 // Maximum number of entries that we are willing to collect in our map. 86 // Maximum number of entries that we are willing to collect in our map.
92 static const unsigned int kMaximumNumberOfEntries; 87 static const unsigned int kMaximumNumberOfEntries;
93 // Number of requests that will be made between garbage collection. 88 // Number of requests that will be made between garbage collection.
94 static const unsigned int kRequestsBetweenCollecting; 89 static const unsigned int kRequestsBetweenCollecting;
95 90
96 // Constructor copies the string "MAGICZZ\0" into this buffer; using it
97 // to try to detect memory overwrites affecting url_entries_ in the wild.
98 // TODO(joi): Remove once crbug.com/71721 is figured out.
99 char magic_buffer_1_[8];
100
101 // Map that contains a list of URL ID and their matching 91 // Map that contains a list of URL ID and their matching
102 // URLRequestThrottlerEntry. 92 // URLRequestThrottlerEntry.
103 UrlEntryMap url_entries_; 93 UrlEntryMap url_entries_;
104 94
105 // Constructor copies the string "GOOGYZZ\0" into this buffer; using it
106 // to try to detect memory overwrites affecting url_entries_ in the wild.
107 // TODO(joi): Remove once crbug.com/71721 is figured out.
108 char magic_buffer_2_[8];
109
110 // This keeps track of how many requests have been made. Used with 95 // This keeps track of how many requests have been made. Used with
111 // GarbageCollectEntries. 96 // GarbageCollectEntries.
112 unsigned int requests_since_last_gc_; 97 unsigned int requests_since_last_gc_;
113 98
114 // Valid after construction. 99 // Valid after construction.
115 GURL::Replacements url_id_replacements_; 100 GURL::Replacements url_id_replacements_;
116 101
117 // Whether we would like to reject outgoing HTTP requests during the back-off 102 // Whether we would like to reject outgoing HTTP requests during the back-off
118 // period. 103 // period.
119 bool enforce_throttling_; 104 bool enforce_throttling_;
120 105
121 // Certain tests do not obey the net component's threading policy, so we 106 // Certain tests do not obey the net component's threading policy, so we
122 // keep track of whether we're being used by tests, and turn off certain 107 // keep track of whether we're being used by tests, and turn off certain
123 // checks. 108 // checks.
124 // 109 //
125 // TODO(joi): See if we can fix the offending unit tests and remove this 110 // TODO(joi): See if we can fix the offending unit tests and remove this
126 // workaround. 111 // workaround.
127 bool being_tested_; 112 bool being_tested_;
128 113
129 base::ThreadCheckerImpl thread_checker_;
130
131 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); 114 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager);
132 }; 115 };
133 116
134 } // namespace net 117 } // namespace net
135 118
136 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ 119 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_throttler_header_adapter.h ('k') | net/url_request/url_request_throttler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698