Chromium Code Reviews| Index: components/ntp_snippets/reading_list/reading_list_distillation_state_util.cc |
| diff --git a/components/ntp_snippets/reading_list/reading_list_distillation_state_util.cc b/components/ntp_snippets/reading_list/reading_list_distillation_state_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6cf986e15272f239a56fe3655d07d61d2fa331a8 |
| --- /dev/null |
| +++ b/components/ntp_snippets/reading_list/reading_list_distillation_state_util.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/ntp_snippets/reading_list/reading_list_distillation_state_util.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace ntp_snippets { |
| + |
| +ReadingListEntry::DistillationState ReadingListStateFromSuggestionState( |
| + ReadingListSuggestionExtra::ReadingListSuggestionDistilledState |
| + distilled_state) { |
| + switch (distilled_state) { |
| + case ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + PROCESSING: |
| + return ReadingListEntry::PROCESSING; |
|
Olivier
2017/03/30 08:51:11
WAITING seems to be a moew default state than PROC
gambard
2017/03/30 08:59:09
Done.
|
| + case ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + SUCCESS: |
| + return ReadingListEntry::PROCESSED; |
| + case ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + FAILURE: |
| + return ReadingListEntry::DISTILLATION_ERROR; |
| + } |
| + NOTREACHED(); |
| + return ReadingListEntry::PROCESSING; |
| +} |
| + |
| +ReadingListSuggestionExtra::ReadingListSuggestionDistilledState |
| +SuggestionStateFromReadingListState( |
| + ReadingListEntry::DistillationState distilled_state) { |
| + switch (distilled_state) { |
| + case ReadingListEntry::WILL_RETRY: |
| + case ReadingListEntry::PROCESSING: |
| + case ReadingListEntry::WAITING: |
| + return ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + PROCESSING; |
|
Olivier
2017/03/30 08:51:11
nit: PROCESSING does not really match WILL_RETRY |
gambard
2017/03/30 08:59:09
Done.
|
| + case ReadingListEntry::PROCESSED: |
| + return ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + SUCCESS; |
| + case ReadingListEntry::DISTILLATION_ERROR: |
| + return ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + FAILURE; |
| + } |
| + NOTREACHED(); |
| + return ReadingListSuggestionExtra::ReadingListSuggestionDistilledState:: |
| + PROCESSING; |
| +} |
| + |
| +} // namespace ntp_snippets |