| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SYNC_BASE_PROTO_VALUE_PTR_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_PROTO_VALUE_PTR_H_ |
| 6 #define COMPONENTS_SYNC_BASE_PROTO_VALUE_PTR_H_ | 6 #define COMPONENTS_SYNC_BASE_PROTO_VALUE_PTR_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/trace_event/memory_usage_estimator.h" |
| 10 | 11 |
| 11 namespace syncer { | 12 namespace syncer { |
| 12 | 13 |
| 13 class ProcessorEntityTracker; | 14 class ProcessorEntityTracker; |
| 14 struct EntityData; | 15 struct EntityData; |
| 15 | 16 |
| 16 namespace syncable { | 17 namespace syncable { |
| 17 struct EntryKernel; | 18 struct EntryKernel; |
| 18 } // namespace syncable | 19 } // namespace syncable |
| 19 | 20 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 121 |
| 121 void load(const void* blob, int length) { | 122 void load(const void* blob, int length) { |
| 122 wrapper_ = Wrapper::ParseFromBlob(blob, length); | 123 wrapper_ = Wrapper::ParseFromBlob(blob, length); |
| 123 } | 124 } |
| 124 | 125 |
| 125 scoped_refptr<Wrapper> wrapper_; | 126 scoped_refptr<Wrapper> wrapper_; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 template <typename T, typename Traits> | 129 template <typename T, typename Traits> |
| 129 size_t EstimateMemoryUsage(const ProtoValuePtr<T, Traits>& ptr) { | 130 size_t EstimateMemoryUsage(const ProtoValuePtr<T, Traits>& ptr) { |
| 131 // Including estimators from base::trace_event (memory_usage_estimator.h) |
| 132 // allows to resolve EstimateMemoryUsage name in cases when T is not a sync |
| 133 // protobuf and thus sync_pb::EstimateMemoryUsage doesn't get matched. |
| 134 using base::trace_event::EstimateMemoryUsage; |
| 130 return &ptr.value() != &Traits::DefaultValue() | 135 return &ptr.value() != &Traits::DefaultValue() |
| 131 ? EstimateMemoryUsage(ptr.value()) | 136 ? EstimateMemoryUsage(ptr.value()) |
| 132 : 0; | 137 : 0; |
| 133 } | 138 } |
| 134 | 139 |
| 135 } // namespace syncer | 140 } // namespace syncer |
| 136 | 141 |
| 137 #endif // COMPONENTS_SYNC_BASE_PROTO_VALUE_PTR_H_ | 142 #endif // COMPONENTS_SYNC_BASE_PROTO_VALUE_PTR_H_ |
| OLD | NEW |