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

Side by Side Diff: content/browser/background_sync/background_sync_registration.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 months 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
OLDNEW
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 #include "content/browser/background_sync/background_sync_registration.h" 5 #include "content/browser/background_sync/background_sync_registration.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 for (auto& callback : notify_finished_callbacks_) { 42 for (auto& callback : notify_finished_callbacks_) {
43 base::ThreadTaskRunnerHandle::Get()->PostTask( 43 base::ThreadTaskRunnerHandle::Get()->PostTask(
44 FROM_HERE, base::Bind(callback, sync_state_)); 44 FROM_HERE, base::Bind(callback, sync_state_));
45 } 45 }
46 46
47 notify_finished_callbacks_.clear(); 47 notify_finished_callbacks_.clear();
48 } 48 }
49 49
50 bool BackgroundSyncRegistration::HasCompleted() const { 50 bool BackgroundSyncRegistration::HasCompleted() const {
51 switch (sync_state_) { 51 switch (sync_state_) {
52 case BACKGROUND_SYNC_STATE_PENDING: 52 case BackgroundSyncState::PENDING:
53 case BACKGROUND_SYNC_STATE_FIRING: 53 case BackgroundSyncState::FIRING:
54 case BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING: 54 case BackgroundSyncState::REREGISTERED_WHILE_FIRING:
55 case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING: 55 case BackgroundSyncState::UNREGISTERED_WHILE_FIRING:
56 return false; 56 return false;
57 case BACKGROUND_SYNC_STATE_FAILED: 57 case BackgroundSyncState::FAILED:
58 case BACKGROUND_SYNC_STATE_SUCCESS: 58 case BackgroundSyncState::SUCCESS:
59 case BACKGROUND_SYNC_STATE_UNREGISTERED: 59 case BackgroundSyncState::UNREGISTERED:
60 return true; 60 return true;
61 } 61 }
62 NOTREACHED(); 62 NOTREACHED();
63 return false; 63 return false;
64 } 64 }
65 65
66 bool BackgroundSyncRegistration::IsFiring() const { 66 bool BackgroundSyncRegistration::IsFiring() const {
67 switch (sync_state_) { 67 switch (sync_state_) {
68 case BACKGROUND_SYNC_STATE_FIRING: 68 case BackgroundSyncState::FIRING:
69 case BACKGROUND_SYNC_STATE_REREGISTERED_WHILE_FIRING: 69 case BackgroundSyncState::REREGISTERED_WHILE_FIRING:
70 case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING: 70 case BackgroundSyncState::UNREGISTERED_WHILE_FIRING:
71 return true; 71 return true;
72 case BACKGROUND_SYNC_STATE_PENDING: 72 case BackgroundSyncState::PENDING:
73 case BACKGROUND_SYNC_STATE_FAILED: 73 case BackgroundSyncState::FAILED:
74 case BACKGROUND_SYNC_STATE_SUCCESS: 74 case BackgroundSyncState::SUCCESS:
75 case BACKGROUND_SYNC_STATE_UNREGISTERED: 75 case BackgroundSyncState::UNREGISTERED:
76 return false; 76 return false;
77 } 77 }
78 NOTREACHED(); 78 NOTREACHED();
79 return false; 79 return false;
80 } 80 }
81 81
82 void BackgroundSyncRegistration::SetUnregisteredState() { 82 void BackgroundSyncRegistration::SetUnregisteredState() {
83 DCHECK(!HasCompleted()); 83 DCHECK(!HasCompleted());
84 84
85 bool is_firing = IsFiring(); 85 bool is_firing = IsFiring();
86 86
87 sync_state_ = is_firing ? BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING 87 sync_state_ = is_firing ? BackgroundSyncState::UNREGISTERED_WHILE_FIRING
88 : BACKGROUND_SYNC_STATE_UNREGISTERED; 88 : BackgroundSyncState::UNREGISTERED;
89 89
90 if (!is_firing) { 90 if (!is_firing) {
91 // If the registration is currently firing then wait to run 91 // If the registration is currently firing then wait to run
92 // RunFinishedCallbacks until after it has finished as it might 92 // RunFinishedCallbacks until after it has finished as it might
93 // change state to SUCCESS first. 93 // change state to SUCCESS first.
94 RunFinishedCallbacks(); 94 RunFinishedCallbacks();
95 } 95 }
96 } 96 }
97 97
98 } // namespace content 98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698