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

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

Issue 2857063002: Add a way to send the resource percentage signal to the RC. (Closed)
Patch Set: CR Feedback per Dimich, BMcQuade, and CSHarrison Created 3 years, 7 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 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_loader.h" 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Add this signal to signal_data_. 192 // Add this signal to signal_data_.
193 AddLoadingSignal("Snapshotting"); 193 AddLoadingSignal("Snapshotting");
194 194
195 HandleLoadEvent(); 195 HandleLoadEvent();
196 } 196 }
197 197
198 bool PrerenderingLoader::IsLowbarMet() { 198 bool PrerenderingLoader::IsLowbarMet() {
199 return is_lowbar_met_; 199 return is_lowbar_met_;
200 } 200 }
201 201
202 void PrerenderingLoader::ObserveResourceTracking(
203 const Offliner::ResourceDataType type,
204 int64_t started_count,
205 int64_t completed_count) {
206 // Add the signal to extra data, and use for tracking.
207 if (type == Offliner::ResourceDataType::IMAGE) {
208 double percentage = 100 * static_cast<double>(completed_count) /
209 static_cast<double>(started_count);
210 // TODO(petewil): Use actual signal type instead of hardcoding name.
211 signal_data_.SetDouble("ImagePercentage", percentage);
212 signal_data_.SetDouble("StartedImages", started_count);
213 signal_data_.SetDouble("CompletedImages", completed_count);
214 }
215 }
216
202 void PrerenderingLoader::HandleLoadEvent() { 217 void PrerenderingLoader::HandleLoadEvent() {
203 // If still loading, check if the load succeeded or not, then update 218 // If still loading, check if the load succeeded or not, then update
204 // the internal state (LOADED for success or IDLE for failure) and post 219 // the internal state (LOADED for success or IDLE for failure) and post
205 // callback. 220 // callback.
206 // Note: it is possible to receive a load event (e.g., if timeout-based) 221 // Note: it is possible to receive a load event (e.g., if timeout-based)
207 // after the request has completed via another path (e.g., canceled) so 222 // after the request has completed via another path (e.g., canceled) so
208 // the Loader may be idle at this point. 223 // the Loader may be idle at this point.
209 224
210 if (IsIdle() || IsLoaded()) 225 if (IsIdle() || IsLoaded())
211 return; 226 return;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (adapter_->IsActive()) { 292 if (adapter_->IsActive()) {
278 adapter_->DestroyActive(); 293 adapter_->DestroyActive();
279 } 294 }
280 snapshot_controller_.reset(nullptr); 295 snapshot_controller_.reset(nullptr);
281 session_contents_.reset(nullptr); 296 session_contents_.reset(nullptr);
282 state_ = State::IDLE; 297 state_ = State::IDLE;
283 is_lowbar_met_ = false; 298 is_lowbar_met_ = false;
284 } 299 }
285 300
286 } // namespace offline_pages 301 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698