OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/offline_pages/core/prefetch/prefetch_proto_utils.h" | 5 #include "components/offline_pages/core/prefetch/prefetch_proto_utils.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "components/offline_pages/core/prefetch/proto/any.pb.h" | 9 #include "components/offline_pages/core/prefetch/proto/any.pb.h" |
10 #include "components/offline_pages/core/prefetch/proto/offline_pages.pb.h" | 10 #include "components/offline_pages/core/prefetch/proto/offline_pages.pb.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 std::vector<RenderPageInfo>* pages) { | 116 std::vector<RenderPageInfo>* pages) { |
117 if (!operation.has_metadata()) { | 117 if (!operation.has_metadata()) { |
118 DVLOG(1) << "metadata not found in GeneratePageBundle response"; | 118 DVLOG(1) << "metadata not found in GeneratePageBundle response"; |
119 return false; | 119 return false; |
120 } | 120 } |
121 return ParsePageBundleInAnyData(operation.metadata(), pages); | 121 return ParsePageBundleInAnyData(operation.metadata(), pages); |
122 } | 122 } |
123 | 123 |
124 } // namespace | 124 } // namespace |
125 | 125 |
126 bool ParseOperationResponse(const std::string& data, | 126 std::string ParseOperationResponse(const std::string& data, |
127 std::vector<RenderPageInfo>* pages) { | 127 std::vector<RenderPageInfo>* pages) { |
128 proto::Operation operation; | 128 proto::Operation operation; |
129 if (!operation.ParseFromString(data)) { | 129 if (!operation.ParseFromString(data)) { |
130 DVLOG(1) << "Failed to parse operation"; | 130 DVLOG(1) << "Failed to parse operation"; |
131 return false; | 131 return std::string(); |
132 } | 132 } |
133 | 133 |
134 if (operation.done()) | 134 std::string name = operation.name(); |
135 return ParseDoneOperationResponse(operation, pages); | 135 bool success = operation.done() |
136 else | 136 ? ParseDoneOperationResponse(operation, pages) |
137 return ParsePendingOperationResponse(operation, pages); | 137 : ParsePendingOperationResponse(operation, pages); |
| 138 return success ? name : std::string(); |
138 } | 139 } |
139 | 140 |
140 } // namespace offline_pages | 141 } // namespace offline_pages |
OLD | NEW |