Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa_data_provider.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/media_galleries/fileapi/picasa_data_provider.h" 5 #include "chrome/browser/media_galleries/fileapi/picasa_data_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 albums_index_ready_callbacks_.push_back(ready_callback); 79 albums_index_ready_callbacks_.push_back(ready_callback);
80 } 80 }
81 DoRefreshIfNecessary(); 81 DoRefreshIfNecessary();
82 } 82 }
83 83
84 std::unique_ptr<AlbumMap> PicasaDataProvider::GetFolders() { 84 std::unique_ptr<AlbumMap> PicasaDataProvider::GetFolders() {
85 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 85 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
86 DCHECK(state_ == LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE || 86 DCHECK(state_ == LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE ||
87 state_ == ALBUMS_IMAGES_FRESH_STATE); 87 state_ == ALBUMS_IMAGES_FRESH_STATE);
88 return base::WrapUnique(new AlbumMap(folder_map_)); 88 return base::MakeUnique<AlbumMap>(folder_map_);
89 } 89 }
90 90
91 std::unique_ptr<AlbumMap> PicasaDataProvider::GetAlbums() { 91 std::unique_ptr<AlbumMap> PicasaDataProvider::GetAlbums() {
92 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 92 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
93 DCHECK(state_ == LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE || 93 DCHECK(state_ == LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE ||
94 state_ == ALBUMS_IMAGES_FRESH_STATE); 94 state_ == ALBUMS_IMAGES_FRESH_STATE);
95 return base::WrapUnique(new AlbumMap(album_map_)); 95 return base::MakeUnique<AlbumMap>(album_map_);
96 } 96 }
97 97
98 std::unique_ptr<AlbumImages> PicasaDataProvider::FindAlbumImages( 98 std::unique_ptr<AlbumImages> PicasaDataProvider::FindAlbumImages(
99 const std::string& key, 99 const std::string& key,
100 base::File::Error* error) { 100 base::File::Error* error) {
101 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 101 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
102 DCHECK(state_ == ALBUMS_IMAGES_FRESH_STATE); 102 DCHECK(state_ == ALBUMS_IMAGES_FRESH_STATE);
103 DCHECK(error); 103 DCHECK(error);
104 104
105 AlbumImagesMap::const_iterator it = albums_images_.find(key); 105 AlbumImagesMap::const_iterator it = albums_images_.find(key);
106 106
107 if (it == albums_images_.end()) { 107 if (it == albums_images_.end()) {
108 *error = base::File::FILE_ERROR_NOT_FOUND; 108 *error = base::File::FILE_ERROR_NOT_FOUND;
109 return std::unique_ptr<AlbumImages>(); 109 return std::unique_ptr<AlbumImages>();
110 } 110 }
111 111
112 *error = base::File::FILE_OK; 112 *error = base::File::FILE_OK;
113 return base::WrapUnique(new AlbumImages(it->second)); 113 return base::MakeUnique<AlbumImages>(it->second);
114 } 114 }
115 115
116 void PicasaDataProvider::InvalidateData() { 116 void PicasaDataProvider::InvalidateData() {
117 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 117 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
118 118
119 // Set data state to stale and ignore responses from any in-flight processes. 119 // Set data state to stale and ignore responses from any in-flight processes.
120 // TODO(tommycli): Implement and call Cancel function for these 120 // TODO(tommycli): Implement and call Cancel function for these
121 // UtilityProcessHostClients to actually kill the in-flight processes. 121 // UtilityProcessHostClients to actually kill the in-flight processes.
122 state_ = STALE_DATA_STATE; 122 state_ = STALE_DATA_STATE;
123 album_table_reader_ = NULL; 123 album_table_reader_ = NULL;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (total_counts[name] != 1) { 258 if (total_counts[name] != 1) {
259 name = base::StringPrintf("%s (%d)", name.c_str(), 259 name = base::StringPrintf("%s (%d)", name.c_str(),
260 ++current_counts[name]); 260 ++current_counts[name]);
261 } 261 }
262 262
263 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i])); 263 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i]));
264 } 264 }
265 } 265 }
266 266
267 } // namespace picasa 267 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698