| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_REPORTING_REPORTING_CONTEXT_H_ | 5 #ifndef NET_REPORTING_REPORTING_CONTEXT_H_ |
| 6 #define NET_REPORTING_REPORTING_CONTEXT_H_ | 6 #define NET_REPORTING_REPORTING_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "net/base/backoff_entry.h" | 12 #include "net/base/backoff_entry.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 #include "net/reporting/reporting_policy.h" | 14 #include "net/reporting/reporting_policy.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class Clock; | 17 class Clock; |
| 18 class TickClock; | 18 class TickClock; |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class ReportingCache; | 23 class ReportingCache; |
| 24 class ReportingDelegate; | 24 class ReportingDelegate; |
| 25 class ReportingDeliveryAgent; | 25 class ReportingDeliveryAgent; |
| 26 class ReportingEndpointManager; | 26 class ReportingEndpointManager; |
| 27 class ReportingGarbageCollector; |
| 27 class ReportingObserver; | 28 class ReportingObserver; |
| 28 class ReportingUploader; | 29 class ReportingUploader; |
| 29 class URLRequestContext; | 30 class URLRequestContext; |
| 30 | 31 |
| 31 // Contains the various internal classes that make up the Reporting system. | 32 // Contains the various internal classes that make up the Reporting system. |
| 32 // Wrapped by ReportingService, which provides the external interface. | 33 // Wrapped by ReportingService, which provides the external interface. |
| 33 class NET_EXPORT ReportingContext { | 34 class NET_EXPORT ReportingContext { |
| 34 public: | 35 public: |
| 35 static std::unique_ptr<ReportingContext> Create( | 36 static std::unique_ptr<ReportingContext> Create( |
| 36 const ReportingPolicy& policy, | 37 const ReportingPolicy& policy, |
| 37 std::unique_ptr<ReportingDelegate> delegate, | 38 std::unique_ptr<ReportingDelegate> delegate, |
| 38 URLRequestContext* request_context); | 39 URLRequestContext* request_context); |
| 39 | 40 |
| 40 ~ReportingContext(); | 41 ~ReportingContext(); |
| 41 | 42 |
| 42 const ReportingPolicy& policy() { return policy_; } | 43 const ReportingPolicy& policy() { return policy_; } |
| 43 ReportingDelegate* delegate() { return delegate_.get(); } | 44 ReportingDelegate* delegate() { return delegate_.get(); } |
| 44 | 45 |
| 45 base::Clock* clock() { return clock_.get(); } | 46 base::Clock* clock() { return clock_.get(); } |
| 46 base::TickClock* tick_clock() { return tick_clock_.get(); } | 47 base::TickClock* tick_clock() { return tick_clock_.get(); } |
| 47 ReportingUploader* uploader() { return uploader_.get(); } | 48 ReportingUploader* uploader() { return uploader_.get(); } |
| 48 | 49 |
| 49 ReportingCache* cache() { return cache_.get(); } | 50 ReportingCache* cache() { return cache_.get(); } |
| 50 ReportingEndpointManager* endpoint_manager() { | 51 ReportingEndpointManager* endpoint_manager() { |
| 51 return endpoint_manager_.get(); | 52 return endpoint_manager_.get(); |
| 52 } | 53 } |
| 53 ReportingDeliveryAgent* delivery_agent() { return delivery_agent_.get(); } | 54 ReportingDeliveryAgent* delivery_agent() { return delivery_agent_.get(); } |
| 55 ReportingGarbageCollector* garbage_collector() { |
| 56 return garbage_collector_.get(); |
| 57 } |
| 54 | 58 |
| 55 void AddObserver(ReportingObserver* observer); | 59 void AddObserver(ReportingObserver* observer); |
| 56 void RemoveObserver(ReportingObserver* observer); | 60 void RemoveObserver(ReportingObserver* observer); |
| 57 | 61 |
| 58 void NotifyCacheUpdated(); | 62 void NotifyCacheUpdated(); |
| 59 | 63 |
| 60 protected: | 64 protected: |
| 61 ReportingContext(const ReportingPolicy& policy, | 65 ReportingContext(const ReportingPolicy& policy, |
| 62 std::unique_ptr<ReportingDelegate> delegate, | 66 std::unique_ptr<ReportingDelegate> delegate, |
| 63 std::unique_ptr<base::Clock> clock, | 67 std::unique_ptr<base::Clock> clock, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 76 | 80 |
| 77 std::unique_ptr<ReportingCache> cache_; | 81 std::unique_ptr<ReportingCache> cache_; |
| 78 | 82 |
| 79 // |endpoint_manager_| must come after |tick_clock_| and |cache_|. | 83 // |endpoint_manager_| must come after |tick_clock_| and |cache_|. |
| 80 std::unique_ptr<ReportingEndpointManager> endpoint_manager_; | 84 std::unique_ptr<ReportingEndpointManager> endpoint_manager_; |
| 81 | 85 |
| 82 // |delivery_agent_| must come after |tick_clock_|, |uploader_|, |cache_|, | 86 // |delivery_agent_| must come after |tick_clock_|, |uploader_|, |cache_|, |
| 83 // and |endpoint_manager_|. | 87 // and |endpoint_manager_|. |
| 84 std::unique_ptr<ReportingDeliveryAgent> delivery_agent_; | 88 std::unique_ptr<ReportingDeliveryAgent> delivery_agent_; |
| 85 | 89 |
| 90 // |garbage_collector_| must come after |tick_clock_| and |cache_|. |
| 91 std::unique_ptr<ReportingGarbageCollector> garbage_collector_; |
| 92 |
| 86 DISALLOW_COPY_AND_ASSIGN(ReportingContext); | 93 DISALLOW_COPY_AND_ASSIGN(ReportingContext); |
| 87 }; | 94 }; |
| 88 | 95 |
| 89 } // namespace net | 96 } // namespace net |
| 90 | 97 |
| 91 #endif // NET_REPORTING_REPORTING_CONTEXT_H_ | 98 #endif // NET_REPORTING_REPORTING_CONTEXT_H_ |
| OLD | NEW |