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

Side by Side Diff: chrome/utility/extensions/extensions_handler.cc

Issue 2867013002: Use OnceCallback on Mojo interfaces in //chrome/common/extensions (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « chrome/common/extensions/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/utility/extensions/extensions_handler.h" 5 #include "chrome/utility/extensions/extensions_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 std::move(request)); 54 std::move(request));
55 } 55 }
56 56
57 private: 57 private:
58 // extensions::mojom::MediaParser: 58 // extensions::mojom::MediaParser:
59 void ParseMediaMetadata( 59 void ParseMediaMetadata(
60 const std::string& mime_type, 60 const std::string& mime_type,
61 int64_t total_size, 61 int64_t total_size,
62 bool get_attached_images, 62 bool get_attached_images,
63 extensions::mojom::MediaDataSourcePtr media_data_source, 63 extensions::mojom::MediaDataSourcePtr media_data_source,
64 const ParseMediaMetadataCallback& callback) override { 64 ParseMediaMetadataCallback callback) override {
65 auto source = base::MakeUnique<metadata::IPCDataSource>( 65 auto source = base::MakeUnique<metadata::IPCDataSource>(
66 std::move(media_data_source), total_size); 66 std::move(media_data_source), total_size);
67 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 67 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
68 std::move(source), mime_type, get_attached_images); 68 std::move(source), mime_type, get_attached_images);
69 parser->Start(base::Bind(&MediaParserImpl::ParseMediaMetadataDone, callback, 69 parser->Start(base::Bind(&MediaParserImpl::ParseMediaMetadataDone,
70 base::Owned(parser))); 70 base::Passed(&callback), base::Owned(parser)));
71 } 71 }
72 72
73 static void ParseMediaMetadataDone( 73 static void ParseMediaMetadataDone(
74 const ParseMediaMetadataCallback& callback, 74 ParseMediaMetadataCallback callback,
75 metadata::MediaMetadataParser* /* parser */, 75 metadata::MediaMetadataParser* /* parser */,
76 const extensions::api::media_galleries::MediaMetadata& metadata, 76 const extensions::api::media_galleries::MediaMetadata& metadata,
77 const std::vector<metadata::AttachedImage>& attached_images) { 77 const std::vector<metadata::AttachedImage>& attached_images) {
78 callback.Run(true, metadata.ToValue(), attached_images); 78 std::move(callback).Run(true, metadata.ToValue(), attached_images);
79 } 79 }
80 80
81 void CheckMediaFile(base::TimeDelta decode_time, 81 void CheckMediaFile(base::TimeDelta decode_time,
82 base::File file, 82 base::File file,
83 const CheckMediaFileCallback& callback) override { 83 CheckMediaFileCallback callback) override {
84 #if !defined(MEDIA_DISABLE_FFMPEG) 84 #if !defined(MEDIA_DISABLE_FFMPEG)
85 media::MediaFileChecker checker(std::move(file)); 85 media::MediaFileChecker checker(std::move(file));
86 callback.Run(checker.Start(decode_time)); 86 std::move(callback).Run(checker.Start(decode_time));
87 #else 87 #else
88 callback.Run(false); 88 std::move(callback).Run(false);
89 #endif 89 #endif
90 } 90 }
91 91
92 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl); 92 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl);
93 }; 93 };
94 94
95 class RemovableStorageWriterImpl 95 class RemovableStorageWriterImpl
96 : public extensions::mojom::RemovableStorageWriter { 96 : public extensions::mojom::RemovableStorageWriter {
97 public: 97 public:
98 RemovableStorageWriterImpl() = default; 98 RemovableStorageWriterImpl() = default;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 static void Create(const service_manager::BindSourceInfo& source_info, 134 static void Create(const service_manager::BindSourceInfo& source_info,
135 extensions::mojom::WiFiCredentialsGetterRequest request) { 135 extensions::mojom::WiFiCredentialsGetterRequest request) {
136 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(), 136 mojo::MakeStrongBinding(base::MakeUnique<WiFiCredentialsGetterImpl>(),
137 std::move(request)); 137 std::move(request));
138 } 138 }
139 139
140 private: 140 private:
141 // extensions::mojom::WiFiCredentialsGetter: 141 // extensions::mojom::WiFiCredentialsGetter:
142 void GetWiFiCredentials(const std::string& ssid, 142 void GetWiFiCredentials(const std::string& ssid,
143 const GetWiFiCredentialsCallback& callback) override { 143 GetWiFiCredentialsCallback callback) override {
144 if (ssid == kWiFiTestNetwork) { 144 if (ssid == kWiFiTestNetwork) {
145 callback.Run(true, ssid); // test-mode: return the ssid in key_data. 145 // test-mode: return the ssid in key_data.
146 std::move(callback).Run(true, ssid);
146 return; 147 return;
147 } 148 }
148 149
149 std::unique_ptr<wifi::WiFiService> wifi_service( 150 std::unique_ptr<wifi::WiFiService> wifi_service(
150 wifi::WiFiService::Create()); 151 wifi::WiFiService::Create());
151 wifi_service->Initialize(nullptr); 152 wifi_service->Initialize(nullptr);
152 153
153 std::string key_data; 154 std::string key_data;
154 std::string error; 155 std::string error;
155 wifi_service->GetKeyFromSystem(ssid, &key_data, &error); 156 wifi_service->GetKeyFromSystem(ssid, &key_data, &error);
156 157
157 const bool success = error.empty(); 158 const bool success = error.empty();
158 if (!success) 159 if (!success)
159 key_data.clear(); 160 key_data.clear();
160 161
161 callback.Run(success, key_data); 162 std::move(callback).Run(success, key_data);
162 } 163 }
163 164
164 DISALLOW_COPY_AND_ASSIGN(WiFiCredentialsGetterImpl); 165 DISALLOW_COPY_AND_ASSIGN(WiFiCredentialsGetterImpl);
165 }; 166 };
166 #endif // defined(OS_WIN) 167 #endif // defined(OS_WIN)
167 168
168 } // namespace 169 } // namespace
169 170
170 namespace extensions { 171 namespace extensions {
171 172
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 picasa::PicasaAlbumsIndexer indexer(album_uids); 282 picasa::PicasaAlbumsIndexer indexer(album_uids);
282 indexer.ParseFolderINI(folders_inis); 283 indexer.ParseFolderINI(folders_inis);
283 content::UtilityThread::Get()->Send( 284 content::UtilityThread::Get()->Send(
284 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 285 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
285 indexer.albums_images())); 286 indexer.albums_images()));
286 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 287 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
287 } 288 }
288 #endif // defined(OS_WIN) || defined(OS_MACOSX) 289 #endif // defined(OS_WIN) || defined(OS_MACOSX)
289 290
290 } // namespace extensions 291 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698