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

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

Issue 998803003: Checks to enforce relative lifetimes for SdchManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated comments and fixed else clause. Created 5 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
« no previous file with comments | « no previous file | net/base/sdch_manager.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 // This file contains the SdchManager class and two nested classes 5 // This file contains the SdchManager class and two nested classes
6 // (Dictionary, DictionarySet). SdchManager::Dictionary contains all 6 // (Dictionary, DictionarySet). SdchManager::Dictionary contains all
7 // of the information about an SDCH dictionary. The manager is 7 // of the information about an SDCH dictionary. The manager is
8 // responsible for storing those dictionaries, and provides access to 8 // responsible for storing those dictionaries, and provides access to
9 // them through DictionarySet objects. A DictionarySet is an object 9 // them through DictionarySet objects. A DictionarySet is an object
10 // whose lifetime is under the control of the consumer. It is a 10 // whose lifetime is under the control of the consumer. It is a
11 // reference to a set of dictionaries, and guarantees that none of 11 // reference to a set of dictionaries, and guarantees that none of
12 // those dictionaries will be destroyed while the DictionarySet 12 // those dictionaries will be destroyed while the DictionarySet
13 // reference is alive. 13 // reference is alive.
14 14
15 #ifndef NET_BASE_SDCH_MANAGER_H_ 15 #ifndef NET_BASE_SDCH_MANAGER_H_
16 #define NET_BASE_SDCH_MANAGER_H_ 16 #define NET_BASE_SDCH_MANAGER_H_
17 17
18 #include <map> 18 #include <map>
19 #include <set> 19 #include <set>
20 #include <string> 20 #include <string>
21 #include <vector> 21 #include <vector>
22 22
23 #include "base/gtest_prod_util.h" 23 #include "base/gtest_prod_util.h"
24 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
26 #include "base/memory/weak_ptr.h"
26 #include "base/observer_list.h" 27 #include "base/observer_list.h"
27 #include "base/threading/thread_checker.h" 28 #include "base/threading/thread_checker.h"
28 #include "base/time/time.h" 29 #include "base/time/time.h"
29 #include "net/base/net_export.h" 30 #include "net/base/net_export.h"
30 #include "net/base/sdch_problem_codes.h" 31 #include "net/base/sdch_problem_codes.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 33
33 namespace base { 34 namespace base {
34 class Clock; 35 class Clock;
35 class Value; 36 class Value;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 286
286 // Remove an SDCH dictionary 287 // Remove an SDCH dictionary
287 SdchProblemCode RemoveSdchDictionary(const std::string& server_hash); 288 SdchProblemCode RemoveSdchDictionary(const std::string& server_hash);
288 289
289 // Registration for events generated by the SDCH subsystem. 290 // Registration for events generated by the SDCH subsystem.
290 void AddObserver(SdchObserver* observer); 291 void AddObserver(SdchObserver* observer);
291 void RemoveObserver(SdchObserver* observer); 292 void RemoveObserver(SdchObserver* observer);
292 293
293 static scoped_ptr<DictionarySet> CreateEmptyDictionarySetForTesting(); 294 static scoped_ptr<DictionarySet> CreateEmptyDictionarySetForTesting();
294 295
296 // For investigation of http://crbug.com/454198; remove when resolved.
297 base::WeakPtr<SdchManager> GetWeakPtr();
298
295 private: 299 private:
296 struct BlacklistInfo { 300 struct BlacklistInfo {
297 BlacklistInfo() : count(0), exponential_count(0), reason(SDCH_OK) {} 301 BlacklistInfo() : count(0), exponential_count(0), reason(SDCH_OK) {}
298 302
299 int count; // # of times to refuse SDCH advertisement. 303 int count; // # of times to refuse SDCH advertisement.
300 int exponential_count; // Current exponential backoff ratchet. 304 int exponential_count; // Current exponential backoff ratchet.
301 SdchProblemCode reason; // Why domain was blacklisted. 305 SdchProblemCode reason; // Why domain was blacklisted.
302 }; 306 };
303 307
304 typedef std::map<std::string, BlacklistInfo> DomainBlacklistInfo; 308 typedef std::map<std::string, BlacklistInfo> DomainBlacklistInfo;
(...skipping 26 matching lines...) Expand all
331 ExperimentSet allow_latency_experiment_; 335 ExperimentSet allow_latency_experiment_;
332 336
333 // Observers that want to be notified of SDCH events. 337 // Observers that want to be notified of SDCH events.
334 // Assert list is empty on destruction since if there is an observer 338 // Assert list is empty on destruction since if there is an observer
335 // that hasn't removed itself from the list, that observer probably 339 // that hasn't removed itself from the list, that observer probably
336 // has a reference to the SdchManager. 340 // has a reference to the SdchManager.
337 ObserverList<SdchObserver, true> observers_; 341 ObserverList<SdchObserver, true> observers_;
338 342
339 base::ThreadChecker thread_checker_; 343 base::ThreadChecker thread_checker_;
340 344
345 base::WeakPtrFactory<SdchManager> factory_;
346
341 DISALLOW_COPY_AND_ASSIGN(SdchManager); 347 DISALLOW_COPY_AND_ASSIGN(SdchManager);
342 }; 348 };
343 349
344 } // namespace net 350 } // namespace net
345 351
346 #endif // NET_BASE_SDCH_MANAGER_H_ 352 #endif // NET_BASE_SDCH_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/sdch_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698