Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: media/base/state_machine.cc

Issue 2568663002: [WIP] - trying out some state machine ideas.
Patch Set: added SimpleStateMachine, updated example Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/state_machine.h ('k') | media/base/state_machine_driver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "media/base/state_machine.h"
6
7 namespace media {
8
9 StateMachine::StateMachine() : owner_(nullptr) {}
10
11 StateMachine::~StateMachine() {
12 for (scoped_refptr<State> state : states_)
13 state->UnregisterClient(this);
14 }
15
16 void StateMachine::SetOwner(Owner* owner) {
17 owner_ = owner;
18 }
19
20 void StateMachine::OnStateChanged() {
21 DCHECK(owner_);
22 owner_->RequestRun(this);
23 }
24
25 void StateMachine::UsingState(scoped_refptr<State> state) {
26 // TODO(liberato): check for duplicates. Not sure why set doesn't work,
27 // since it seems like there should be a default hash defined for refptr.
28 // maybe define one if not, but probably i just forgot to tell the set
29 // about it.
30 state->RegisterClient(this);
31 states_.push_back(state);
32 }
33
34 } // namespace media
OLDNEW
« no previous file with comments | « media/base/state_machine.h ('k') | media/base/state_machine_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698