OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 if (prerender_contents.get() == NULL) | 538 if (prerender_contents.get() == NULL) |
539 return false; | 539 return false; |
540 | 540 |
541 // Do not use the prerendered version if the opener window.property was | 541 // Do not use the prerendered version if the opener window.property was |
542 // supposed to be set. | 542 // supposed to be set. |
543 if (has_opener_set) { | 543 if (has_opener_set) { |
544 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER); | 544 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER); |
545 return false; | 545 return false; |
546 } | 546 } |
547 | 547 |
548 if (prerender_contents->starting_page_id() <= | |
549 tab_contents->GetMaxPageID()) { | |
550 prerender_contents.release()->Destroy(FINAL_STATUS_PAGE_ID_CONFLICT); | |
551 return false; | |
552 } | |
553 | |
554 // If we are just in the control group (which can be detected by noticing | 548 // If we are just in the control group (which can be detected by noticing |
555 // that prerendering hasn't even started yet), record that |tab_contents| now | 549 // that prerendering hasn't even started yet), record that |tab_contents| now |
556 // would be showing a prerendered contents, but otherwise, don't do anything. | 550 // would be showing a prerendered contents, but otherwise, don't do anything. |
557 if (!prerender_contents->prerendering_has_started()) { | 551 if (!prerender_contents->prerendering_has_started()) { |
558 MarkTabContentsAsWouldBePrerendered(tab_contents); | 552 MarkTabContentsAsWouldBePrerendered(tab_contents); |
559 return false; | 553 return false; |
560 } | 554 } |
561 | 555 |
| 556 if (prerender_contents->starting_page_id() <= |
| 557 tab_contents->GetMaxPageID()) { |
| 558 prerender_contents.release()->Destroy(FINAL_STATUS_PAGE_ID_CONFLICT); |
| 559 return false; |
| 560 } |
| 561 |
562 int child_id, route_id; | 562 int child_id, route_id; |
563 CHECK(prerender_contents->GetChildId(&child_id)); | 563 CHECK(prerender_contents->GetChildId(&child_id)); |
564 CHECK(prerender_contents->GetRouteId(&route_id)); | 564 CHECK(prerender_contents->GetRouteId(&route_id)); |
565 | 565 |
566 // Try to set the prerendered page as used, so any subsequent attempts to | 566 // Try to set the prerendered page as used, so any subsequent attempts to |
567 // cancel on other threads will fail. If this fails because the prerender | 567 // cancel on other threads will fail. If this fails because the prerender |
568 // was already cancelled, possibly on another thread, fail. | 568 // was already cancelled, possibly on another thread, fail. |
569 if (!PrerenderTracker::GetInstance()->TryUse(child_id, route_id)) | 569 if (!PrerenderTracker::GetInstance()->TryUse(child_id, route_id)) |
570 return false; | 570 return false; |
571 | 571 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 base::TimeTicks cutoff = GetCurrentTimeTicks() - | 1009 base::TimeTicks cutoff = GetCurrentTimeTicks() - |
1010 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); | 1010 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); |
1011 while (!navigations_.empty()) { | 1011 while (!navigations_.empty()) { |
1012 if (navigations_.front().time_ > cutoff) | 1012 if (navigations_.front().time_ > cutoff) |
1013 break; | 1013 break; |
1014 navigations_.pop_front(); | 1014 navigations_.pop_front(); |
1015 } | 1015 } |
1016 } | 1016 } |
1017 | 1017 |
1018 } // namespace prerender | 1018 } // namespace prerender |
OLD | NEW |