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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 PREVIEW_NUM_TYPES + 1, base::Histogram::kUmaTargetedHistogramFlag); | 72 PREVIEW_NUM_TYPES + 1, base::Histogram::kUmaTargetedHistogramFlag); |
73 histogram->Add(usage); | 73 histogram->Add(usage); |
74 } | 74 } |
75 | 75 |
76 void AddSessionStorageHistogram(InstantController::Mode mode, | 76 void AddSessionStorageHistogram(InstantController::Mode mode, |
77 const TabContents* tab1, | 77 const TabContents* tab1, |
78 const TabContents* tab2) { | 78 const TabContents* tab2) { |
79 base::Histogram* histogram = base::BooleanHistogram::FactoryGet( | 79 base::Histogram* histogram = base::BooleanHistogram::FactoryGet( |
80 "Instant.SessionStorageNamespace" + ModeToString(mode), | 80 "Instant.SessionStorageNamespace" + ModeToString(mode), |
81 base::Histogram::kUmaTargetedHistogramFlag); | 81 base::Histogram::kUmaTargetedHistogramFlag); |
82 histogram->AddBoolean( | 82 const content::SessionStorageNamespaceMap& session_storage_map1 = |
83 tab1->web_contents()->GetController().GetSessionStorageNamespace() == | 83 tab1->web_contents()->GetController().GetSessionStorageNamespaceMap(); |
84 tab2->web_contents()->GetController().GetSessionStorageNamespace()); | 84 const content::SessionStorageNamespaceMap& session_storage_map2 = |
| 85 tab2->web_contents()->GetController().GetSessionStorageNamespaceMap(); |
| 86 bool is_session_storage_the_same = |
| 87 session_storage_map1.size() == session_storage_map2.size(); |
| 88 if (is_session_storage_the_same) { |
| 89 // The size is the same, so let's check that all entries match. |
| 90 for (content::SessionStorageNamespaceMap::const_iterator |
| 91 it1 = session_storage_map1.begin(), |
| 92 it2 = session_storage_map2.begin(); |
| 93 it1 != session_storage_map1.end() && |
| 94 it2 != session_storage_map2.end(); |
| 95 ++it1, ++it2) { |
| 96 if (it1->first != it2->first || it1->second != it2->second) { |
| 97 is_session_storage_the_same = false; |
| 98 break; |
| 99 } |
| 100 } |
| 101 } |
| 102 histogram->AddBoolean(is_session_storage_the_same); |
85 } | 103 } |
86 | 104 |
87 } // namespace | 105 } // namespace |
88 | 106 |
89 InstantController::InstantController(InstantControllerDelegate* delegate, | 107 InstantController::InstantController(InstantControllerDelegate* delegate, |
90 Mode mode) | 108 Mode mode) |
91 : delegate_(delegate), | 109 : delegate_(delegate), |
92 mode_(mode), | 110 mode_(mode), |
93 last_active_tab_(NULL), | 111 last_active_tab_(NULL), |
94 last_verbatim_(false), | 112 last_verbatim_(false), |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return false; | 598 return false; |
581 } | 599 } |
582 | 600 |
583 return true; | 601 return true; |
584 } | 602 } |
585 | 603 |
586 bool InstantController::IsOutOfDate() const { | 604 bool InstantController::IsOutOfDate() const { |
587 return !last_active_tab_ || | 605 return !last_active_tab_ || |
588 last_active_tab_ != delegate_->GetActiveTabContents(); | 606 last_active_tab_ != delegate_->GetActiveTabContents(); |
589 } | 607 } |
OLD | NEW |