OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 DCHECK_EQ(1U, alias_urls_.size()); | 280 DCHECK_EQ(1U, alias_urls_.size()); |
281 | 281 |
282 session_storage_namespace_id_ = session_storage_namespace->id(); | 282 session_storage_namespace_id_ = session_storage_namespace->id(); |
283 bounds_ = bounds; | 283 bounds_ = bounds; |
284 | 284 |
285 DCHECK(load_start_time_.is_null()); | 285 DCHECK(load_start_time_.is_null()); |
286 load_start_time_ = base::TimeTicks::Now(); | 286 load_start_time_ = base::TimeTicks::Now(); |
287 | 287 |
288 prerendering_has_started_ = true; | 288 prerendering_has_started_ = true; |
289 | 289 |
290 prerender_contents_.reset(CreateWebContents(session_storage_namespace)); | 290 content::WebContents::CreateParams create_params = |
291 TabHelpers::AttachTabHelpers(prerender_contents_.get()); | 291 WebContents::CreateParams(profile_); |
| 292 prerender_contents_.reset( |
| 293 CreateWebContents(create_params, session_storage_namespace)); |
| 294 TabHelpers::AttachTabHelpers(prerender_contents_.get(), create_params); |
292 content::WebContentsObserver::Observe(prerender_contents_.get()); | 295 content::WebContentsObserver::Observe(prerender_contents_.get()); |
293 | 296 |
294 // Tag the prerender contents with the task manager specific prerender tag, so | 297 // Tag the prerender contents with the task manager specific prerender tag, so |
295 // that it shows up in the task manager. | 298 // that it shows up in the task manager. |
296 task_manager::WebContentsTags::CreateForPrerenderContents( | 299 task_manager::WebContentsTags::CreateForPrerenderContents( |
297 prerender_contents_.get()); | 300 prerender_contents_.get()); |
298 | 301 |
299 web_contents_delegate_.reset(new WebContentsDelegateImpl(this)); | 302 web_contents_delegate_.reset(new WebContentsDelegateImpl(this)); |
300 prerender_contents_.get()->SetDelegate(web_contents_delegate_.get()); | 303 prerender_contents_.get()->SetDelegate(web_contents_delegate_.get()); |
301 // Set the size of the prerender WebContents. | 304 // Set the size of the prerender WebContents. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 NOTREACHED() << "Unexpected notification sent."; | 443 NOTREACHED() << "Unexpected notification sent."; |
441 break; | 444 break; |
442 } | 445 } |
443 } | 446 } |
444 | 447 |
445 void PrerenderContents::OnRenderViewHostCreated( | 448 void PrerenderContents::OnRenderViewHostCreated( |
446 RenderViewHost* new_render_view_host) { | 449 RenderViewHost* new_render_view_host) { |
447 } | 450 } |
448 | 451 |
449 WebContents* PrerenderContents::CreateWebContents( | 452 WebContents* PrerenderContents::CreateWebContents( |
| 453 const content::WebContents::CreateParams& create_params, |
450 SessionStorageNamespace* session_storage_namespace) { | 454 SessionStorageNamespace* session_storage_namespace) { |
451 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 455 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
452 // multiple session storage namespaces per tab. | 456 // multiple session storage namespaces per tab. |
453 content::SessionStorageNamespaceMap session_storage_namespace_map; | 457 content::SessionStorageNamespaceMap session_storage_namespace_map; |
454 session_storage_namespace_map[std::string()] = session_storage_namespace; | 458 session_storage_namespace_map[std::string()] = session_storage_namespace; |
455 return WebContents::CreateWithSessionStorage( | 459 return WebContents::CreateWithSessionStorage(create_params, |
456 WebContents::CreateParams(profile_), session_storage_namespace_map); | 460 session_storage_namespace_map); |
457 } | 461 } |
458 | 462 |
459 void PrerenderContents::NotifyPrerenderStart() { | 463 void PrerenderContents::NotifyPrerenderStart() { |
460 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); | 464 DCHECK_EQ(FINAL_STATUS_MAX, final_status_); |
461 for (Observer& observer : observer_list_) | 465 for (Observer& observer : observer_list_) |
462 observer.OnPrerenderStart(this); | 466 observer.OnPrerenderStart(this); |
463 } | 467 } |
464 | 468 |
465 void PrerenderContents::NotifyPrerenderStopLoading() { | 469 void PrerenderContents::NotifyPrerenderStopLoading() { |
466 for (Observer& observer : observer_list_) | 470 for (Observer& observer : observer_list_) |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 idle_resources_.push_back(throttle); | 793 idle_resources_.push_back(throttle); |
790 } | 794 } |
791 | 795 |
792 void PrerenderContents::AddNetworkBytes(int64_t bytes) { | 796 void PrerenderContents::AddNetworkBytes(int64_t bytes) { |
793 network_bytes_ += bytes; | 797 network_bytes_ += bytes; |
794 for (Observer& observer : observer_list_) | 798 for (Observer& observer : observer_list_) |
795 observer.OnPrerenderNetworkBytesChanged(this); | 799 observer.OnPrerenderNetworkBytesChanged(this); |
796 } | 800 } |
797 | 801 |
798 } // namespace prerender | 802 } // namespace prerender |
OLD | NEW |