Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_ | |
| 6 #define CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/string16.h" | |
| 12 | |
| 13 namespace browser { | |
|
sky
2011/03/11 00:00:45
We generally don't use namespaces in cases like th
MAD
2011/03/11 03:01:37
Done.
| |
| 14 | |
| 15 // This exposes a static method that receives a vector of TitleInfo objects | |
| 16 // so that it can find the length of the common prefixes among all the titles. | |
|
sky
2011/03/11 00:00:45
Imagine if you didn't write this class and went to
MAD
2011/03/11 03:01:37
Done.
| |
| 17 class TitlePrefixMatcher { | |
| 18 public: | |
| 19 struct TitleInfo { | |
| 20 TitleInfo(const string16* title, int caller_value) | |
| 21 : title(title), prefix_length(0), caller_value(caller_value) {} | |
|
sky
2011/03/11 00:00:45
Since you wrapper, each param should be on its own
MAD
2011/03/11 03:01:37
Done.
| |
| 22 TitleInfo(const TitleInfo& other) | |
|
sky
2011/03/11 00:00:45
How come you wrote copy constructor/assignment ope
MAD
2011/03/11 03:01:37
Done.
This was needed in a previous iteration when
| |
| 23 : title(other.title), | |
| 24 prefix_length(other.prefix_length), | |
| 25 caller_value(other.caller_value) { | |
| 26 } | |
| 27 TitleInfo& operator=(const TitleInfo& other) { | |
| 28 title = other.title; | |
| 29 prefix_length = other.prefix_length; | |
| 30 caller_value = other.caller_value; | |
| 31 return *this; | |
| 32 } | |
| 33 // We assume the title string will be valid throughout the execution of | |
| 34 // the prefix lengths calculation, and use a pointer to avoid an uncessary | |
| 35 // string copy. | |
| 36 const string16* title; | |
| 37 size_t prefix_length; | |
| 38 int caller_value; // Unused by CalculatePrefixLengths. | |
| 39 }; | |
| 40 static void CalculatePrefixLengths(std::vector<TitleInfo>* title_infos); | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(TitlePrefixMatcher); | |
|
sky
2011/03/11 00:00:45
after private. But you probably want DISALLOW_IMPL
MAD
2011/03/11 03:01:37
Done.
| |
| 43 }; | |
| 44 | |
| 45 } // namespace browser | |
| 46 | |
| 47 #endif // CHROME_BROWSER_UI_TITLE_PREFIX_MATCHER_H_ | |
| OLD | NEW |