diff options
-rw-r--r-- | chrome/browser/history/history_backend_unittest.cc | 23 | ||||
-rw-r--r-- | styleguide/c++/c++11.html | 25 | ||||
-rw-r--r-- | ui/base/layout.cc | 8 |
3 files changed, 28 insertions, 28 deletions
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index 8127b01..9ed2b3fb 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -65,18 +65,6 @@ typedef base::Callback<void(const history::URLRow*, const history::URLRow*)> SimulateNotificationCallback; -// Comparison functions as to make it easier to check results of -// GetFaviconBitmaps() and GetIconMappingsForPageURL(). -bool IconMappingLessThan(const history::IconMapping& a, - const history::IconMapping& b) { - return a.icon_url < b.icon_url; -} - -bool FaviconBitmapLessThan(const history::FaviconBitmap& a, - const history::FaviconBitmap& b) { - return a.pixel_size.GetArea() < b.pixel_size.GetArea(); -} - class HistoryClientMock : public history::HistoryClientFakeBookmarks { public: MOCK_METHOD0(BlockUntilBookmarksLoaded, void()); @@ -368,7 +356,9 @@ class HistoryBackendTest : public HistoryBackendTestBase { return false; } std::sort(icon_mappings->begin(), icon_mappings->end(), - IconMappingLessThan); + [](const history::IconMapping& a, const history::IconMapping& b) { + return a.icon_url < b.icon_url; + }); return true; } @@ -378,8 +368,11 @@ class HistoryBackendTest : public HistoryBackendTestBase { std::vector<FaviconBitmap>* favicon_bitmaps) { if (!backend_->thumbnail_db_->GetFaviconBitmaps(icon_id, favicon_bitmaps)) return false; - std::sort(favicon_bitmaps->begin(), favicon_bitmaps->end(), - FaviconBitmapLessThan); + std::sort( + favicon_bitmaps->begin(), favicon_bitmaps->end(), + [](const history::FaviconBitmap& a, const history::FaviconBitmap& b) { + return a.pixel_size.GetArea() < b.pixel_size.GetArea(); + }); return true; } diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html index 6d870fb..f99a8eb 100644 --- a/styleguide/c++/c++11.html +++ b/styleguide/c++/c++11.html @@ -116,6 +116,23 @@ enum classes and regular enums.</td> </tr> <tr> +<td>Lambda Expressions</td> +<td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</code></td> +<td>Anonymous functions</td> +<td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td> +<td>Do not bind or store lambdas; use <code>base::Bind</code> and +<code>base::Callback</code> instead, because they offer protection against a +large class of object lifetime mistakes. Don't use default captures +(<code>[=]</code>, <code>[&]</code> – <a + href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions">Google Style Guide</a>). +Lambdas are typically useful as a parameter to methods or +functions that will use them immediately, such as those in +<code><algorithm></code>. <a + href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion + thread</a></td> +</tr> + +<tr> <td>Local Types as Template Arguments</td> <td></td> <td>Allows local and unnamed types as template arguments</td> @@ -415,14 +432,6 @@ synthetic function such as a copy constructor</td> </tr> <tr> -<td>Lambda Expressions</td> -<td><code>[<i>captures</i>](<i>params</i>) -> <i>ret</i> { <i>body</i> }</code></td> -<td>Anonymous functions</td> -<td><a href="http://en.cppreference.com/w/cpp/language/lambda">Lambda functions</a></td> -<td>No default captures (<a href="https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Lambda_expressions">Google Style Guide</a>). <a href="https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/D9UnnxBnciQ">Discussion thread</a></td> -</tr> - -<tr> <td>Non-Static Class Member Initializers</td> <td> <code> diff --git a/ui/base/layout.cc b/ui/base/layout.cc index 0c3802b..01c5b00 100644 --- a/ui/base/layout.cc +++ b/ui/base/layout.cc @@ -28,10 +28,6 @@ namespace ui { namespace { -bool ScaleFactorComparator(const ScaleFactor& lhs, const ScaleFactor& rhs){ - return GetScaleForScaleFactor(lhs) < GetScaleForScaleFactor(rhs); -} - std::vector<ScaleFactor>* g_supported_scale_factors = NULL; const float kScaleFactorScales[] = {1.0f, 1.0f, 1.25f, 1.33f, 1.4f, 1.5f, 1.8f, @@ -49,7 +45,9 @@ void SetSupportedScaleFactors( g_supported_scale_factors = new std::vector<ScaleFactor>(scale_factors); std::sort(g_supported_scale_factors->begin(), g_supported_scale_factors->end(), - ScaleFactorComparator); + [](ScaleFactor lhs, ScaleFactor rhs) { + return GetScaleForScaleFactor(lhs) < GetScaleForScaleFactor(rhs); + }); // Set ImageSkia's supported scales. std::vector<float> scales; |