OLD | NEW |
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 "components/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 switch (state) { | 972 switch (state) { |
973 case State::NOT_INITED: | 973 case State::NOT_INITED: |
974 // Initial state, it should not be possible to get back there. | 974 // Initial state, it should not be possible to get back there. |
975 NOTREACHED(); | 975 NOTREACHED(); |
976 return; | 976 return; |
977 | 977 |
978 case State::READY: { | 978 case State::READY: { |
979 DCHECK(state_ == State::NOT_INITED || state_ == State::DISABLED); | 979 DCHECK(state_ == State::NOT_INITED || state_ == State::DISABLED); |
980 | 980 |
| 981 // TODO(jkrcal): fetching snippets automatically upon creation of this |
| 982 // lazily created service can cause troubles, e.g. in unittests where |
| 983 // network I/O is not allowed. |
| 984 // Either add a DCHECK here that we actually are allowed to do network I/O |
| 985 // or change the logic so that some explicit call is always needed for the |
| 986 // network request. |
981 bool fetch_snippets = | 987 bool fetch_snippets = |
982 categories_[articles_category_].snippets.empty() || fetch_after_load_; | 988 categories_[articles_category_].snippets.empty() || fetch_after_load_; |
983 DVLOG(1) << "Entering state: READY"; | 989 DVLOG(1) << "Entering state: READY"; |
984 state_ = State::READY; | 990 state_ = State::READY; |
985 fetch_after_load_ = false; | 991 fetch_after_load_ = false; |
986 EnterStateEnabled(fetch_snippets); | 992 EnterStateEnabled(fetch_snippets); |
987 return; | 993 return; |
988 } | 994 } |
989 | 995 |
990 case State::DISABLED: | 996 case State::DISABLED: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 } | 1061 } |
1056 | 1062 |
1057 NTPSnippetsService::CategoryContent::CategoryContent() = default; | 1063 NTPSnippetsService::CategoryContent::CategoryContent() = default; |
1058 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) = | 1064 NTPSnippetsService::CategoryContent::CategoryContent(CategoryContent&&) = |
1059 default; | 1065 default; |
1060 NTPSnippetsService::CategoryContent::~CategoryContent() = default; | 1066 NTPSnippetsService::CategoryContent::~CategoryContent() = default; |
1061 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent:: | 1067 NTPSnippetsService::CategoryContent& NTPSnippetsService::CategoryContent:: |
1062 operator=(CategoryContent&&) = default; | 1068 operator=(CategoryContent&&) = default; |
1063 | 1069 |
1064 } // namespace ntp_snippets | 1070 } // namespace ntp_snippets |
OLD | NEW |