Commit 5f8a3365 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Clarify adding << operator in example.

Add
- decl in .h file and impl in .cc
- hint about needing CONTENT_EXPORT

Change-Id: I463315e961c2c80e713f1aee8e1da72b6d86a5ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2237436
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Auto-Submit: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779260}
parent 6a29d906
......@@ -19,32 +19,41 @@ namespace content {
// implementation favours convenience and simplicity over performance. To use it
// follow this example:
// #include "base/no_destructor.h"
// #include "content/common/state_transitions.h"
//
// In foo.h
// ---------
// enum class State {
// kState1,
// kState2,
// kState3,
// };
//
// #if DCHECK_IS_ON()
// // This may require exporting the symbol (e.g. CONTENT_EXPORT) if it will be
// // used by any other components: one common way this can happen is if the
// // enum is logged in tests (e.g. via gtest's EXPECT_* macros).
// std::ostream& operator<<(std::ostream& o, const State& s);
// ---------
//
// In foo.cc
// ---------
// #include "base/no_destructor.h"
// #include "content/common/state_transitions.h"
//
// std::ostream& operator<<(std::ostream& o, const State& s) {
// return o << static_cast<int>(s);
// }
// #endif // DCHECK_IS_ON()
//
// void DCheckStateTransition(State old_state, State new_state) {
// #if DCHECK_IS_ON()
// static const base::NoDestructor<StateTransitions<LifecycleState>>
// static const base::NoDestructor<StateTransitions<State>>
// transitions(
// StateTransitions<LifecycleState>(
// StateTransitions<State>(
// {{kState1, {kState2, kState3}},
// {kState2, {kState3}},
// {kState3, {}}}));
// DCHECK_STATE_TRANSITION(transitions, old_state, new_state);
// #endif // DCHECK_IS_ON()
// }
// ---------
template <typename State>
struct StateTransitions {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment