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

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

Issue 2357013002: Fix an issue that PrerenderLoader::OnPrerenderStart() never gets called. (Closed)
Patch Set: Created 4 years, 3 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/prerender_adapter.h" 5 #include "chrome/browser/android/offline_pages/prerender_adapter.h"
6 6
7 #include "chrome/browser/prerender/prerender_manager.h" 7 #include "chrome/browser/prerender/prerender_manager.h"
8 #include "chrome/browser/prerender/prerender_manager_factory.h" 8 #include "chrome/browser/prerender/prerender_manager_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 26 matching lines...) Expand all
37 const gfx::Size& size) { 37 const gfx::Size& size) {
38 DCHECK(!IsActive()); 38 DCHECK(!IsActive());
39 DCHECK(CanPrerender()); 39 DCHECK(CanPrerender());
40 40
41 Profile* profile = Profile::FromBrowserContext(browser_context); 41 Profile* profile = Profile::FromBrowserContext(browser_context);
42 prerender::PrerenderManager* manager = 42 prerender::PrerenderManager* manager =
43 prerender::PrerenderManagerFactory::GetForProfile(profile); 43 prerender::PrerenderManagerFactory::GetForProfile(profile);
44 DCHECK(manager); 44 DCHECK(manager);
45 45
46 // Start prerendering the url and capture the handle for the prerendering. 46 // Start prerendering the url and capture the handle for the prerendering.
47 // Note: PrerenderHandle::OnPrerenderStart() will get called inside
48 // PrerenderManager::AddPrerenderForOffline(), this is before the observer is
49 // set.
47 active_handle_ = 50 active_handle_ =
48 manager->AddPrerenderForOffline(url, session_storage_namespace, size); 51 manager->AddPrerenderForOffline(url, session_storage_namespace, size);
49 if (!active_handle_) 52 if (!active_handle_)
50 return false; 53 return false;
54 DCHECK(active_handle_->contents());
55 DCHECK(active_handle_->contents()->prerendering_has_started());
51 56
52 active_handle_->SetObserver(this); 57 active_handle_->SetObserver(this);
58
53 return true; 59 return true;
54 } 60 }
55 61
56 content::WebContents* PrerenderAdapter::GetWebContents() const { 62 content::WebContents* PrerenderAdapter::GetWebContents() const {
57 DCHECK(IsActive()); 63 DCHECK(IsActive());
58 DCHECK(active_handle_->contents()); 64 DCHECK(active_handle_->contents());
59 // Note: the prerender stack maintains ownership of these contents 65 // Note: the prerender stack maintains ownership of these contents
60 // and PrerenderingLoader::StopLoading() must be called to report 66 // and PrerenderingLoader::StopLoading() must be called to report
61 // the Loader is done with the contents. 67 // the Loader is done with the contents.
62 return active_handle_->contents()->prerender_contents(); 68 return active_handle_->contents()->prerender_contents();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 105 }
100 106
101 void PrerenderAdapter::OnPrerenderStop(prerender::PrerenderHandle* handle) { 107 void PrerenderAdapter::OnPrerenderStop(prerender::PrerenderHandle* handle) {
102 if (IsActive()) { 108 if (IsActive()) {
103 DCHECK_EQ(active_handle_.get(), handle); 109 DCHECK_EQ(active_handle_.get(), handle);
104 observer_->OnPrerenderStop(); 110 observer_->OnPrerenderStop();
105 } 111 }
106 } 112 }
107 113
108 } // namespace offline_pages 114 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698