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

Side by Side Diff: components/domain_reliability/util.h

Issue 252613002: Domain Reliability: More security review. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ;_; Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ 6 #define COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/tracked_objects.h" 13 #include "base/tracked_objects.h"
14 #include "components/domain_reliability/domain_reliability_export.h" 14 #include "components/domain_reliability/domain_reliability_export.h"
15 15
16 namespace domain_reliability { 16 namespace domain_reliability {
17 17
18 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUtil { 18 // Attempts to convert a net error and an HTTP response code into the status
19 public: 19 // string that should be recorded in a beacon. Returns true if it could.
20 // Attempts to convert a net error and an HTTP response code into the status 20 //
21 // string that should be recorded in a beacon. Returns true if it could. 21 // N.B.: This functions as the whitelist of "safe" errors to report; network-
22 static bool GetBeaconStatus( 22 // local errors are purposefully not converted to avoid revealing
23 int net_error, 23 // information about the local network to the remote server.
24 int http_response_code, 24 bool GetDomainReliabilityBeaconStatus(
25 std::string* beacon_status_out); 25 int net_error,
26 }; 26 int http_response_code,
27 std::string* beacon_status_out);
27 28
28 // Mockable wrapper around TimeTicks::Now and Timer. Mock version is in 29 // Mockable wrapper around TimeTicks::Now and Timer. Mock version is in
29 // test_util.h. 30 // test_util.h.
31 // TODO(ttuttle): Rename to Time{Provider,Source,?}.
30 class DOMAIN_RELIABILITY_EXPORT MockableTime { 32 class DOMAIN_RELIABILITY_EXPORT MockableTime {
31 public: 33 public:
32 // Mockable wrapper around (a subset of) base::Timer. 34 // Mockable wrapper around (a subset of) base::Timer.
33 class DOMAIN_RELIABILITY_EXPORT Timer { 35 class DOMAIN_RELIABILITY_EXPORT Timer {
34 public: 36 public:
35 virtual ~Timer(); 37 virtual ~Timer();
36 38
37 virtual void Start(const tracked_objects::Location& posted_from, 39 virtual void Start(const tracked_objects::Location& posted_from,
38 base::TimeDelta delay, 40 base::TimeDelta delay,
39 const base::Closure& user_task) = 0; 41 const base::Closure& user_task) = 0;
(...skipping 18 matching lines...) Expand all
58 60
59 private: 61 private:
60 DISALLOW_COPY_AND_ASSIGN(MockableTime); 62 DISALLOW_COPY_AND_ASSIGN(MockableTime);
61 }; 63 };
62 64
63 // Implementation of MockableTime that passes through to 65 // Implementation of MockableTime that passes through to
64 // base::Time{,Ticks}::Now() and base::Timer. 66 // base::Time{,Ticks}::Now() and base::Timer.
65 class DOMAIN_RELIABILITY_EXPORT ActualTime : public MockableTime { 67 class DOMAIN_RELIABILITY_EXPORT ActualTime : public MockableTime {
66 public: 68 public:
67 ActualTime(); 69 ActualTime();
70
68 virtual ~ActualTime(); 71 virtual ~ActualTime();
69 72
70 // MockableTime implementation: 73 // MockableTime implementation:
71 virtual base::Time Now() OVERRIDE; 74 virtual base::Time Now() OVERRIDE;
72 virtual base::TimeTicks NowTicks() OVERRIDE; 75 virtual base::TimeTicks NowTicks() OVERRIDE;
73 virtual scoped_ptr<MockableTime::Timer> CreateTimer() OVERRIDE; 76 virtual scoped_ptr<MockableTime::Timer> CreateTimer() OVERRIDE;
74 }; 77 };
75 78
76 } // namespace domain_reliability 79 } // namespace domain_reliability
77 80
78 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_ 81 #endif // COMPONENTS_DOMAIN_RELIABILITY_UTIL_H_
OLDNEW
« no previous file with comments | « components/domain_reliability/uploader_unittest.cc ('k') | components/domain_reliability/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698