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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_proto_utils.cc

Issue 2928243002: Return operation name in prefetch request callback and add internal page hookup (Closed)
Patch Set: Fix comment indent in JS Created 3 years, 6 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 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698