| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 PrerenderingLoader::~PrerenderingLoader() { | 88 PrerenderingLoader::~PrerenderingLoader() { |
| 89 CancelPrerender(); | 89 CancelPrerender(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void PrerenderingLoader::MarkLoadStartTime() { | 92 void PrerenderingLoader::MarkLoadStartTime() { |
| 93 load_start_time_ = base::TimeTicks::Now(); | 93 load_start_time_ = base::TimeTicks::Now(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void PrerenderingLoader::AddLoadingSignal(const char* signal_name) { | 96 void PrerenderingLoader::AddLoadingSignal(const char* signal_name) { |
| 97 std::string signal(signal_name); | |
| 98 signal += ": "; | |
| 99 base::TimeTicks current_time = base::TimeTicks::Now(); | 97 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 100 base::TimeDelta delay_so_far = current_time - load_start_time_; | 98 base::TimeDelta delay_so_far = current_time - load_start_time_; |
| 101 signal += std::to_string(delay_so_far.InMilliseconds()); | 99 double delay = delay_so_far.InMilliseconds(); |
| 102 signal_data_.push_back(signal); | 100 signal_data_.SetDouble(signal_name, delay); |
| 103 } | 101 } |
| 104 | 102 |
| 105 bool PrerenderingLoader::LoadPage(const GURL& url, | 103 bool PrerenderingLoader::LoadPage(const GURL& url, |
| 106 const LoadPageCallback& load_done_callback, | 104 const LoadPageCallback& load_done_callback, |
| 107 const ProgressCallback& progress_callback) { | 105 const ProgressCallback& progress_callback) { |
| 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 106 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 109 if (!IsIdle()) { | 107 if (!IsIdle()) { |
| 110 DVLOG(1) | 108 DVLOG(1) |
| 111 << "WARNING: Existing request in progress or waiting for StopLoading()"; | 109 << "WARNING: Existing request in progress or waiting for StopLoading()"; |
| 112 return false; | 110 return false; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (adapter_->IsActive()) { | 293 if (adapter_->IsActive()) { |
| 296 adapter_->DestroyActive(); | 294 adapter_->DestroyActive(); |
| 297 } | 295 } |
| 298 snapshot_controller_.reset(nullptr); | 296 snapshot_controller_.reset(nullptr); |
| 299 session_contents_.reset(nullptr); | 297 session_contents_.reset(nullptr); |
| 300 state_ = State::IDLE; | 298 state_ = State::IDLE; |
| 301 is_lowbar_met_ = false; | 299 is_lowbar_met_ = false; |
| 302 } | 300 } |
| 303 | 301 |
| 304 } // namespace offline_pages | 302 } // namespace offline_pages |
| OLD | NEW |