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

Side by Side Diff: third_party/WebKit/Source/core/page/Page.cpp

Issue 2875793002: Why this CL triggers an OilPan crash.
Patch Set: Created 3 years, 7 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 | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All
3 * Rights Reserved. 3 * Rights Reserved.
4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/page/ValidationMessageClient.h" 54 #include "core/page/ValidationMessageClient.h"
55 #include "core/page/scrolling/OverscrollController.h" 55 #include "core/page/scrolling/OverscrollController.h"
56 #include "core/page/scrolling/ScrollingCoordinator.h" 56 #include "core/page/scrolling/ScrollingCoordinator.h"
57 #include "core/page/scrolling/TopDocumentRootScrollerController.h" 57 #include "core/page/scrolling/TopDocumentRootScrollerController.h"
58 #include "core/paint/PaintLayer.h" 58 #include "core/paint/PaintLayer.h"
59 #include "core/probe/CoreProbes.h" 59 #include "core/probe/CoreProbes.h"
60 #include "platform/WebFrameScheduler.h" 60 #include "platform/WebFrameScheduler.h"
61 #include "platform/graphics/GraphicsLayer.h" 61 #include "platform/graphics/GraphicsLayer.h"
62 #include "platform/loader/fetch/ResourceFetcher.h" 62 #include "platform/loader/fetch/ResourceFetcher.h"
63 #include "platform/plugins/PluginData.h" 63 #include "platform/plugins/PluginData.h"
64 #include "platform/wtf/HashMap.h"
64 #include "public/platform/Platform.h" 65 #include "public/platform/Platform.h"
65 66
66 namespace blink { 67 namespace blink {
67 68
69 namespace {
70
71 using BrowsingInstanceHashMap = WTF::HashMap<int, Page::PageSet>;
72 BrowsingInstanceHashMap& GetBrowsingInstanceHashMap() {
73 DEFINE_STATIC_LOCAL(BrowsingInstanceHashMap, browsing_instance_hash_map,
74 ());
75 return browsing_instance_hash_map;
76 }
77
78 } // namespace
79
68 // Set of all live pages; includes internal Page objects that are 80 // Set of all live pages; includes internal Page objects that are
69 // not observable from scripts. 81 // not observable from scripts.
70 static Page::PageSet& AllPages() { 82 static Page::PageSet& AllPages() {
71 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 83 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
72 return pages; 84 return pages;
73 } 85 }
74 86
75 Page::PageSet& Page::OrdinaryPages() { 87 Page::PageSet& Page::OrdinaryPages() {
76 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 88 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
77 return pages; 89 return pages;
78 } 90 }
79 91
92 const Page::PageSet& Page::RelatedPages() {
93 DEFINE_STATIC_LOCAL(Page::PageSet, empty_page_set, ());
94 if (browsing_instance_id_ == Page::kUnknownBrowsingInstance)
95 return empty_page_set;
96
97 auto it = GetBrowsingInstanceHashMap().find(browsing_instance_id_);
98 DCHECK_NE(GetBrowsingInstanceHashMap().end(), it);
99 return it->value;
100 }
101
80 float DeviceScaleFactorDeprecated(LocalFrame* frame) { 102 float DeviceScaleFactorDeprecated(LocalFrame* frame) {
81 if (!frame) 103 if (!frame)
82 return 1; 104 return 1;
83 Page* page = frame->GetPage(); 105 Page* page = frame->GetPage();
84 if (!page) 106 if (!page)
85 return 1; 107 return 1;
86 return page->DeviceScaleFactorDeprecated(); 108 return page->DeviceScaleFactorDeprecated();
87 } 109 }
88 110
89 Page* Page::CreateOrdinary(PageClients& page_clients) { 111 Page* Page::CreateOrdinary(PageClients& page_clients,
112 int browsing_instance_id) {
90 Page* page = Create(page_clients); 113 Page* page = Create(page_clients);
114
115 page->browsing_instance_id_ = browsing_instance_id;
116 if (browsing_instance_id != Page::kUnknownBrowsingInstance) {
117 auto it = GetBrowsingInstanceHashMap().find(browsing_instance_id);
118 if (it != GetBrowsingInstanceHashMap().end()) {
119 it->value.insert(page);
120 } else {
121 PageSet initial_set;
122 initial_set.insert(page);
123 GetBrowsingInstanceHashMap().insert(browsing_instance_id,
124 std::move(initial_set));
125 }
126 }
127
91 OrdinaryPages().insert(page); 128 OrdinaryPages().insert(page);
92 if (ScopedPageSuspender::IsActive()) 129 if (ScopedPageSuspender::IsActive())
93 page->SetSuspended(true); 130 page->SetSuspended(true);
94 return page; 131 return page;
95 } 132 }
96 133
97 Page::Page(PageClients& page_clients) 134 Page::Page(PageClients& page_clients)
98 : SettingsDelegate(Settings::Create()), 135 : SettingsDelegate(Settings::Create()),
99 animator_(PageAnimator::Create(*this)), 136 animator_(PageAnimator::Create(*this)),
100 autoscroll_controller_(AutoscrollController::Create(*this)), 137 autoscroll_controller_(AutoscrollController::Create(*this)),
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 Frame* main_frame = main_frame_; 687 Frame* main_frame = main_frame_;
651 688
652 // TODO(sashab): Remove this check, the call to detach() here should always 689 // TODO(sashab): Remove this check, the call to detach() here should always
653 // work. 690 // work.
654 if (main_frame->IsAttached()) 691 if (main_frame->IsAttached())
655 main_frame->Detach(FrameDetachType::kRemove); 692 main_frame->Detach(FrameDetachType::kRemove);
656 693
657 DCHECK(AllPages().Contains(this)); 694 DCHECK(AllPages().Contains(this));
658 AllPages().erase(this); 695 AllPages().erase(this);
659 OrdinaryPages().erase(this); 696 OrdinaryPages().erase(this);
697 if (browsing_instance_id_ != Page::kUnknownBrowsingInstance) {
698 auto it = GetBrowsingInstanceHashMap().find(browsing_instance_id_);
699 DCHECK_NE(GetBrowsingInstanceHashMap().end(), it);
700 PageSet& related_pages = it->value;
701 related_pages.erase(this);
702 if (related_pages.IsEmpty())
703 GetBrowsingInstanceHashMap().erase(browsing_instance_id_);
704 }
660 705
661 if (scrolling_coordinator_) 706 if (scrolling_coordinator_)
662 scrolling_coordinator_->WillBeDestroyed(); 707 scrolling_coordinator_->WillBeDestroyed();
663 708
664 GetChromeClient().ChromeDestroyed(); 709 GetChromeClient().ChromeDestroyed();
665 if (validation_message_client_) 710 if (validation_message_client_)
666 validation_message_client_->WillBeDestroyed(); 711 validation_message_client_->WillBeDestroyed();
667 main_frame_ = nullptr; 712 main_frame_ = nullptr;
668 713
669 PageVisibilityNotifier::NotifyContextDestroyed(); 714 PageVisibilityNotifier::NotifyContextDestroyed();
670 } 715 }
671 716
672 Page::PageClients::PageClients() 717 Page::PageClients::PageClients()
673 : chrome_client(nullptr), 718 : chrome_client(nullptr),
674 context_menu_client(nullptr), 719 context_menu_client(nullptr),
675 editor_client(nullptr), 720 editor_client(nullptr),
676 spell_checker_client(nullptr) {} 721 spell_checker_client(nullptr) {}
677 722
678 Page::PageClients::~PageClients() {} 723 Page::PageClients::~PageClients() {}
679 724
680 template class CORE_TEMPLATE_EXPORT Supplement<Page>; 725 template class CORE_TEMPLATE_EXPORT Supplement<Page>;
681 726
682 } // namespace blink 727 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698