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

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

Issue 2548903002: [OfflinePages] Classifies PRERENDERING_FAILED cases whether to TryNext (Closed)
Patch Set: Created 4 years 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 16 matching lines...) Expand all
27 27
28 28
29 namespace offline_pages { 29 namespace offline_pages {
30 30
31 31
32 // Classifies the appropriate RequestStatus for for the given prerender 32 // Classifies the appropriate RequestStatus for for the given prerender
33 // FinalStatus. 33 // FinalStatus.
34 Offliner::RequestStatus ClassifyFinalStatus( 34 Offliner::RequestStatus ClassifyFinalStatus(
35 prerender::FinalStatus final_status) { 35 prerender::FinalStatus final_status) {
36 switch (final_status) { 36 switch (final_status) {
37 37 // Identify aborted/canceled operations.
38 // Identify aborted/canceled operations
39 38
40 case prerender::FINAL_STATUS_CANCELLED: 39 case prerender::FINAL_STATUS_CANCELLED:
41 // TODO(dougarnett): Reconsider if/when get better granularity (642768) 40 // TODO(dougarnett): Reconsider if/when get better granularity (642768)
42 case prerender::FINAL_STATUS_UNSUPPORTED_SCHEME: 41 case prerender::FINAL_STATUS_UNSUPPORTED_SCHEME:
43 return Offliner::PRERENDERING_CANCELED; 42 return Offliner::PRERENDERING_CANCELED;
44 43
45 // Identify non-retryable failues. 44 // Identify non-retryable failures. These are a hard type failures
45 // associated with the page and so are expected to occur again if retried.
46 46
47 case prerender::FINAL_STATUS_SAFE_BROWSING: 47 case prerender::FINAL_STATUS_SAFE_BROWSING:
48 case prerender::FINAL_STATUS_CREATING_AUDIO_STREAM: 48 case prerender::FINAL_STATUS_CREATING_AUDIO_STREAM:
49 case prerender::FINAL_STATUS_JAVASCRIPT_ALERT: 49 case prerender::FINAL_STATUS_JAVASCRIPT_ALERT:
50 case prerender::FINAL_STATUS_CREATE_NEW_WINDOW:
51 case prerender::FINAL_STATUS_INVALID_HTTP_METHOD:
52 case prerender::FINAL_STATUS_OPEN_URL:
50 return Offliner::RequestStatus::PRERENDERING_FAILED_NO_RETRY; 53 return Offliner::RequestStatus::PRERENDERING_FAILED_NO_RETRY;
51 54
55 // Identify failures that indicate we should stop further processing
56 // for now. These may be current resource issues or app closing.
57
58 case prerender::FINAL_STATUS_MEMORY_LIMIT_EXCEEDED:
59 case prerender::FINAL_STATUS_RATE_LIMIT_EXCEEDED:
60 case prerender::FINAL_STATUS_RENDERER_CRASHED:
61 case prerender::FINAL_STATUS_TOO_MANY_PROCESSES:
62 case prerender::FINAL_STATUS_TIMED_OUT:
63 case prerender::FINAL_STATUS_APP_TERMINATING:
64 case prerender::FINAL_STATUS_PROFILE_DESTROYED:
65 return Offliner::RequestStatus::PRERENDERING_FAILED_NO_NEXT;
Pete Williamson 2016/12/02 23:06:09 Should we add a test in prerendering loader unitte
dougarnett 2016/12/02 23:50:08 Yes, thanks
66
52 // Otherwise, assume retryable failure. 67 // Otherwise, assume retryable failure.
68
69 case prerender::FINAL_STATUS_NEW_NAVIGATION_ENTRY:
70 case prerender::FINAL_STATUS_CACHE_OR_HISTORY_CLEARED:
71 case prerender::FINAL_STATUS_SSL_ERROR:
72 case prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED:
73 case prerender::FINAL_STATUS_WINDOW_PRINT:
53 default: 74 default:
54 return Offliner::RequestStatus::PRERENDERING_FAILED; 75 return Offliner::RequestStatus::PRERENDERING_FAILED;
55 } 76 }
56 } 77 }
57 78
58 PrerenderingLoader::PrerenderingLoader(content::BrowserContext* browser_context) 79 PrerenderingLoader::PrerenderingLoader(content::BrowserContext* browser_context)
59 : state_(State::IDLE), 80 : state_(State::IDLE),
60 snapshot_controller_(nullptr), 81 snapshot_controller_(nullptr),
61 browser_context_(browser_context) { 82 browser_context_(browser_context) {
62 adapter_.reset(new PrerenderAdapter(this)); 83 adapter_.reset(new PrerenderAdapter(this));
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void PrerenderingLoader::CancelPrerender() { 258 void PrerenderingLoader::CancelPrerender() {
238 if (adapter_->IsActive()) { 259 if (adapter_->IsActive()) {
239 adapter_->DestroyActive(); 260 adapter_->DestroyActive();
240 } 261 }
241 snapshot_controller_.reset(nullptr); 262 snapshot_controller_.reset(nullptr);
242 session_contents_.reset(nullptr); 263 session_contents_.reset(nullptr);
243 state_ = State::IDLE; 264 state_ = State::IDLE;
244 } 265 }
245 266
246 } // namespace offline_pages 267 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698