| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Immutable<T> provides an easy, cheap, and thread-safe way to pass | 5 // Immutable<T> provides an easy, cheap, and thread-safe way to pass |
| 6 // large immutable data around. | 6 // large immutable data around. |
| 7 // | 7 // |
| 8 // For example, consider the following code: | 8 // For example, consider the following code: |
| 9 // | 9 // |
| 10 // typedef std::vector<LargeObject> LargeObjectList; | 10 // typedef std::vector<LargeObject> LargeObjectList; |
| 11 // | 11 // |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // for discussion) Immutable<T> should be able to find it. | 55 // for discussion) Immutable<T> should be able to find it. |
| 56 // | 56 // |
| 57 // Alternatively, you could explicitly control which swap function is | 57 // Alternatively, you could explicitly control which swap function is |
| 58 // used by providing your own traits class or using one of the | 58 // used by providing your own traits class or using one of the |
| 59 // pre-defined ones below. See comments on traits below for details. | 59 // pre-defined ones below. See comments on traits below for details. |
| 60 // | 60 // |
| 61 // NOTE: Some complexity is necessary in order to use Immutable<T> | 61 // NOTE: Some complexity is necessary in order to use Immutable<T> |
| 62 // with forward-declared types. See comments on traits below for | 62 // with forward-declared types. See comments on traits below for |
| 63 // details. | 63 // details. |
| 64 | 64 |
| 65 #ifndef CHROME_BROWSER_SYNC_UTIL_IMMUTABLE_H_ | 65 #ifndef SYNC_UTIL_IMMUTABLE_H_ |
| 66 #define CHROME_BROWSER_SYNC_UTIL_IMMUTABLE_H_ | 66 #define SYNC_UTIL_IMMUTABLE_H_ |
| 67 #pragma once | 67 #pragma once |
| 68 | 68 |
| 69 // For std::swap(). | 69 // For std::swap(). |
| 70 #include <algorithm> | 70 #include <algorithm> |
| 71 | 71 |
| 72 #include "base/basictypes.h" | 72 #include "base/basictypes.h" |
| 73 #include "base/memory/ref_counted.h" | 73 #include "base/memory/ref_counted.h" |
| 74 | 74 |
| 75 namespace browser_sync { | 75 namespace browser_sync { |
| 76 | 76 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 // Helper function to avoid having to write out template arguments. | 254 // Helper function to avoid having to write out template arguments. |
| 255 template <typename T> | 255 template <typename T> |
| 256 Immutable<T> MakeImmutable(T* t) { | 256 Immutable<T> MakeImmutable(T* t) { |
| 257 return Immutable<T>(t); | 257 return Immutable<T>(t); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace browser_sync | 260 } // namespace browser_sync |
| 261 | 261 |
| 262 #endif // CHROME_BROWSER_SYNC_UTIL_IMMUTABLE_H_ | 262 #endif // SYNC_UTIL_IMMUTABLE_H_ |
| OLD | NEW |