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 it1 = | |
91 session_storage_map1.begin(); | |
92 it1 != session_storage_map1.end(); | |
93 ++it1) { | |
94 | |
95 content::SessionStorageNamespaceMap::const_iterator it2 = | |
96 session_storage_map2.find(it1->first); | |
sreeram
2012/08/09 19:20:05
Since the map is a std::map, with string keys, ite
| |
97 if (it2 == session_storage_map2.end() || | |
98 it1->second != it2->second) { | |
99 is_session_storage_the_same = false; | |
100 break; | |
101 } | |
102 } | |
103 } | |
104 histogram->AddBoolean(is_session_storage_the_same); | |
85 } | 105 } |
86 | 106 |
87 } // namespace | 107 } // namespace |
88 | 108 |
89 InstantController::InstantController(InstantControllerDelegate* delegate, | 109 InstantController::InstantController(InstantControllerDelegate* delegate, |
90 Mode mode) | 110 Mode mode) |
91 : delegate_(delegate), | 111 : delegate_(delegate), |
92 mode_(mode), | 112 mode_(mode), |
93 last_active_tab_(NULL), | 113 last_active_tab_(NULL), |
94 last_verbatim_(false), | 114 last_verbatim_(false), |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 return false; | 600 return false; |
581 } | 601 } |
582 | 602 |
583 return true; | 603 return true; |
584 } | 604 } |
585 | 605 |
586 bool InstantController::IsOutOfDate() const { | 606 bool InstantController::IsOutOfDate() const { |
587 return !last_active_tab_ || | 607 return !last_active_tab_ || |
588 last_active_tab_ != delegate_->GetActiveTabContents(); | 608 last_active_tab_ != delegate_->GetActiveTabContents(); |
589 } | 609 } |
OLD | NEW |