Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BASE_SEQUENCE_TOKEN_H_ | 5 #ifndef BASE_SEQUENCE_TOKEN_H_ |
| 6 #define BASE_SEQUENCE_TOKEN_H_ | 6 #define BASE_SEQUENCE_TOKEN_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 8 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 | 12 |
| 11 namespace base { | 13 namespace base { |
| 12 | 14 |
| 13 // A token that identifies a series of sequenced tasks (i.e. tasks that run one | 15 // A token that identifies a series of sequenced tasks (i.e. tasks that run one |
| 14 // at a time in posting order). | 16 // at a time in posting order). |
| 15 class BASE_EXPORT SequenceToken { | 17 class BASE_EXPORT SequenceToken { |
| 16 public: | 18 public: |
| 17 // Instantiates an invalid SequenceToken. | 19 // Instantiates an invalid SequenceToken. |
| 18 SequenceToken() = default; | 20 SequenceToken() = default; |
| 19 | 21 |
| 20 // Explicitly allow copy. | 22 // Explicitly allow copy. |
| 21 SequenceToken(const SequenceToken& other) = default; | 23 SequenceToken(const SequenceToken& other) = default; |
| 22 SequenceToken& operator=(const SequenceToken& other) = default; | 24 SequenceToken& operator=(const SequenceToken& other) = default; |
| 23 | 25 |
| 24 // An invalid SequenceToken is not equal to any other SequenceToken, including | 26 // An invalid SequenceToken is not equal to any other SequenceToken, including |
| 25 // other invalid SequenceTokens. | 27 // other invalid SequenceTokens. |
| 26 bool operator==(const SequenceToken& other) const; | 28 bool operator==(const SequenceToken& other) const; |
| 27 bool operator!=(const SequenceToken& other) const; | 29 bool operator!=(const SequenceToken& other) const; |
| 28 | 30 |
| 29 // Returns true if this is a valid SequenceToken. | 31 // Returns true if this is a valid SequenceToken. |
| 30 bool IsValid() const; | 32 bool IsValid() const; |
| 31 | 33 |
| 34 // Returns a string with a number uniquely representing this SequenceToken. | |
|
fdoray
2016/10/05 12:39:40
Nobody should use this for logic. Maybe add:
// S
gab
2016/10/05 20:12:43
Done.
| |
| 35 std::string ToString() const; | |
| 36 | |
| 32 // Returns a valid SequenceToken which isn't equal to any previously returned | 37 // Returns a valid SequenceToken which isn't equal to any previously returned |
| 33 // SequenceToken. | 38 // SequenceToken. |
| 34 static SequenceToken Create(); | 39 static SequenceToken Create(); |
| 35 | 40 |
| 36 // Returns the SequenceToken associated with the task running on the current | 41 // Returns the SequenceToken associated with the task running on the current |
| 37 // thread, as determined by the active ScopedSetSequenceTokenForCurrentThread | 42 // thread, as determined by the active ScopedSetSequenceTokenForCurrentThread |
| 38 // if any. | 43 // if any. |
| 39 static SequenceToken GetForCurrentThread(); | 44 static SequenceToken GetForCurrentThread(); |
| 40 | 45 |
| 41 private: | 46 private: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 private: | 107 private: |
| 103 const SequenceToken sequence_token_; | 108 const SequenceToken sequence_token_; |
| 104 const TaskToken task_token_; | 109 const TaskToken task_token_; |
| 105 | 110 |
| 106 DISALLOW_COPY_AND_ASSIGN(ScopedSetSequenceTokenForCurrentThread); | 111 DISALLOW_COPY_AND_ASSIGN(ScopedSetSequenceTokenForCurrentThread); |
| 107 }; | 112 }; |
| 108 | 113 |
| 109 } // namespace base | 114 } // namespace base |
| 110 | 115 |
| 111 #endif // BASE_SEQUENCE_TOKEN_H_ | 116 #endif // BASE_SEQUENCE_TOKEN_H_ |
| OLD | NEW |