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

Side by Side Diff: chrome/browser/android/offline_pages/prerendering_offliner.cc

Issue 2821133003: Write loading signal extra data in JSON (Closed)
Patch Set: fix comment Created 3 years, 8 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
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/offline_pages/prerendering_offliner.h" 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h"
8 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
9 #include "base/sys_info.h" 10 #include "base/sys_info.h"
10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 11 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
11 #include "chrome/browser/android/offline_pages/offliner_helper.h" 12 #include "chrome/browser/android/offline_pages/offliner_helper.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "components/offline_pages/core/background/offliner_policy.h" 14 #include "components/offline_pages/core/background/offliner_policy.h"
14 #include "components/offline_pages/core/background/save_page_request.h" 15 #include "components/offline_pages/core/background/save_page_request.h"
15 #include "components/offline_pages/core/client_namespace_constants.h" 16 #include "components/offline_pages/core/client_namespace_constants.h"
16 #include "components/offline_pages/core/downloads/download_ui_adapter.h" 17 #include "components/offline_pages/core/downloads/download_ui_adapter.h"
17 #include "components/offline_pages/core/offline_page_feature.h" 18 #include "components/offline_pages/core/offline_page_feature.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Clear pending request and app listener then run completion callback. 118 // Clear pending request and app listener then run completion callback.
118 pending_request_.reset(nullptr); 119 pending_request_.reset(nullptr);
119 app_listener_.reset(nullptr); 120 app_listener_.reset(nullptr);
120 completion_callback_.Run(request, load_status); 121 completion_callback_.Run(request, load_status);
121 } 122 }
122 } 123 }
123 124
124 std::string PrerenderingOffliner::SerializeLoadingSignalData() { 125 std::string PrerenderingOffliner::SerializeLoadingSignalData() {
125 // Write the signal data into a single string. 126 // Write the signal data into a single string.
126 std::string signal_string; 127 std::string signal_string;
127 const std::vector<std::string>& signals = loader_->GetLoadingSignalData(); 128 const base::DictionaryValue& signals = loader_->GetLoadingSignalData();
128 129
129 // TODO(petewil): Convert this to JSON, use json_writer.h 130 base::JSONWriter::Write(signals, &signal_string);
130 for (std::string signal : signals) { 131
131 signal_string += signal;
132 signal_string += "\n";
133 }
134 return signal_string; 132 return signal_string;
135 } 133 }
136 134
137 void PrerenderingOffliner::OnSavePageDone( 135 void PrerenderingOffliner::OnSavePageDone(
138 const SavePageRequest& request, 136 const SavePageRequest& request,
139 SavePageResult save_result, 137 SavePageResult save_result,
140 int64_t offline_id) { 138 int64_t offline_id) {
141 // Check if request is still pending receiving a callback. 139 // Check if request is still pending receiving a callback.
142 if (!pending_request_) 140 if (!pending_request_)
143 return; 141 return;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 void PrerenderingOffliner::HandleApplicationStateChangeCancel( 321 void PrerenderingOffliner::HandleApplicationStateChangeCancel(
324 const SavePageRequest& request, 322 const SavePageRequest& request,
325 int64_t offline_id) { 323 int64_t offline_id) {
326 // This shouldn't be immediate, but account for case where request was reset 324 // This shouldn't be immediate, but account for case where request was reset
327 // while waiting for callback. 325 // while waiting for callback.
328 if (pending_request_ && pending_request_->request_id() != offline_id) 326 if (pending_request_ && pending_request_->request_id() != offline_id)
329 return; 327 return;
330 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED); 328 completion_callback_.Run(request, RequestStatus::FOREGROUND_CANCELED);
331 } 329 }
332 } // namespace offline_pages 330 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698