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

Side by Side Diff: chrome/browser/chromeos/login/ui/preloaded_web_view.cc

Issue 2659853005: cros: Fix crash after killing preloaded lock screen in task manager. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | 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/chromeos/login/ui/preloaded_web_view.h" 5 #include "chrome/browser/chromeos/login/ui/preloaded_web_view.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/idle_detector.h" 10 #include "chrome/browser/chromeos/idle_detector.h"
(...skipping 25 matching lines...) Expand all
36 void PreloadedWebView::PreloadOnIdle(PreloadCallback preload) { 36 void PreloadedWebView::PreloadOnIdle(PreloadCallback preload) {
37 preload_function_ = std::move(preload); 37 preload_function_ = std::move(preload);
38 idle_detector_ = base::MakeUnique<chromeos::IdleDetector>( 38 idle_detector_ = base::MakeUnique<chromeos::IdleDetector>(
39 base::Bind(&PreloadedWebView::RunPreloader, weak_factory_.GetWeakPtr())); 39 base::Bind(&PreloadedWebView::RunPreloader, weak_factory_.GetWeakPtr()));
40 idle_detector_->Start( 40 idle_detector_->Start(
41 base::TimeDelta::FromSeconds(kIdleSecondsBeforePreloadingLockScreen)); 41 base::TimeDelta::FromSeconds(kIdleSecondsBeforePreloadingLockScreen));
42 } 42 }
43 43
44 std::unique_ptr<views::WebView> PreloadedWebView::TryTake() { 44 std::unique_ptr<views::WebView> PreloadedWebView::TryTake() {
45 idle_detector_.reset(); 45 idle_detector_.reset();
46
47 // Clear cached reference if it is no longer valid (ie, destroyed in task
48 // manager).
49 if (preloaded_instance_ &&
50 !preloaded_instance_->GetWebContents()
51 ->GetRenderViewHost()
52 ->GetWidget()
53 ->GetView()) {
54 preloaded_instance_.reset();
55 }
56
46 return std::move(preloaded_instance_); 57 return std::move(preloaded_instance_);
47 } 58 }
48 59
49 void PreloadedWebView::Shutdown() { 60 void PreloadedWebView::Shutdown() {
50 preloaded_instance_.reset(); 61 preloaded_instance_.reset();
51 } 62 }
52 63
53 void PreloadedWebView::Observe(int type, 64 void PreloadedWebView::Observe(int type,
54 const content::NotificationSource& source, 65 const content::NotificationSource& source,
55 const content::NotificationDetails& details) { 66 const content::NotificationDetails& details) {
(...skipping 12 matching lines...) Expand all
68 break; 79 break;
69 } 80 }
70 } 81 }
71 82
72 void PreloadedWebView::RunPreloader() { 83 void PreloadedWebView::RunPreloader() {
73 idle_detector_.reset(); 84 idle_detector_.reset();
74 preloaded_instance_ = std::move(preload_function_).Run(profile_); 85 preloaded_instance_ = std::move(preload_function_).Run(profile_);
75 } 86 }
76 87
77 } // namespace chromeos 88 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698