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

Side by Side Diff: components/offline_pages/core/prefetch/generate_page_bundle_request.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/generate_page_bundle_request.h" 5 #include "components/offline_pages/core/prefetch/generate_page_bundle_request.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 "components/offline_pages/core/prefetch/prefetch_proto_utils.h" 10 #include "components/offline_pages/core/prefetch/prefetch_proto_utils.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 base::Bind(&GeneratePageBundleRequest::OnCompleted, 49 base::Bind(&GeneratePageBundleRequest::OnCompleted,
50 // Fetcher is owned by this instance. 50 // Fetcher is owned by this instance.
51 base::Unretained(this))); 51 base::Unretained(this)));
52 } 52 }
53 53
54 GeneratePageBundleRequest::~GeneratePageBundleRequest() {} 54 GeneratePageBundleRequest::~GeneratePageBundleRequest() {}
55 55
56 void GeneratePageBundleRequest::OnCompleted(PrefetchRequestStatus status, 56 void GeneratePageBundleRequest::OnCompleted(PrefetchRequestStatus status,
57 const std::string& data) { 57 const std::string& data) {
58 if (status != PrefetchRequestStatus::SUCCESS) { 58 if (status != PrefetchRequestStatus::SUCCESS) {
59 callback_.Run(status, std::vector<RenderPageInfo>()); 59 callback_.Run(status, std::string(), std::vector<RenderPageInfo>());
60 return; 60 return;
61 } 61 }
62 62
63 std::vector<RenderPageInfo> pages; 63 std::vector<RenderPageInfo> pages;
64 if (!ParseOperationResponse(data, &pages)) { 64 std::string operation_name = ParseOperationResponse(data, &pages);
65 if (operation_name.empty()) {
65 callback_.Run(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF, 66 callback_.Run(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF,
66 std::vector<RenderPageInfo>()); 67 std::string(), std::vector<RenderPageInfo>());
67 return; 68 return;
68 } 69 }
69 70
70 callback_.Run(PrefetchRequestStatus::SUCCESS, pages); 71 callback_.Run(PrefetchRequestStatus::SUCCESS, operation_name, pages);
71 } 72 }
72 73
73 } // offline_pages 74 } // offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698