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

Side by Side Diff: chrome/browser/sync/test/integration/sync_extension_helper.cc

Issue 2461463002: [Sync] Replacing NULL with nullptr/null throughout sync code. (Closed)
Patch Set: Reverted PROFILE_nullptr mistake. Created 4 years, 1 month 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 (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/sync/test/integration/sync_extension_helper.h" 5 #include "chrome/browser/sync/test/integration/sync_extension_helper.h"
6 6
7 #include <list> 7 #include <list>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // extension from the extensions service's copy. 181 // extension from the extensions service's copy.
182 const extensions::PendingExtensionManager* pending_extension_manager = 182 const extensions::PendingExtensionManager* pending_extension_manager =
183 extensions::ExtensionSystem::Get(profile) 183 extensions::ExtensionSystem::Get(profile)
184 ->extension_service() 184 ->extension_service()
185 ->pending_extension_manager(); 185 ->pending_extension_manager();
186 186
187 std::list<std::string> pending_crx_ids; 187 std::list<std::string> pending_crx_ids;
188 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids); 188 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_crx_ids);
189 189
190 std::list<std::string>::const_iterator iter; 190 std::list<std::string>::const_iterator iter;
191 const extensions::PendingExtensionInfo* info = NULL; 191 const extensions::PendingExtensionInfo* info = nullptr;
192 for (iter = pending_crx_ids.begin(); iter != pending_crx_ids.end(); ++iter) { 192 for (iter = pending_crx_ids.begin(); iter != pending_crx_ids.end(); ++iter) {
193 ASSERT_TRUE(info = pending_extension_manager->GetById(*iter)); 193 ASSERT_TRUE(info = pending_extension_manager->GetById(*iter));
194 if (!info->is_from_sync()) 194 if (!info->is_from_sync())
195 continue; 195 continue;
196 196
197 StringMap::const_iterator iter2 = id_to_name_.find(*iter); 197 StringMap::const_iterator iter2 = id_to_name_.find(*iter);
198 if (iter2 == id_to_name_.end()) { 198 if (iter2 == id_to_name_.end()) {
199 ADD_FAILURE() << "Could not get name for id " << *iter 199 ADD_FAILURE() << "Could not get name for id " << *iter
200 << " (profile = " << profile->GetDebugName() << ")"; 200 << " (profile = " << profile->GetDebugName() << ")";
201 continue; 201 continue;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 source.Set(extensions::manifest_keys::kPlatformAppBackground, 352 source.Set(extensions::manifest_keys::kPlatformAppBackground,
353 new base::DictionaryValue()); 353 new base::DictionaryValue());
354 base::ListValue* scripts = new base::ListValue(); 354 base::ListValue* scripts = new base::ListValue();
355 scripts->AppendString("main.js"); 355 scripts->AppendString("main.js");
356 source.Set(extensions::manifest_keys::kPlatformAppBackgroundScripts, 356 source.Set(extensions::manifest_keys::kPlatformAppBackgroundScripts,
357 scripts); 357 scripts);
358 break; 358 break;
359 } 359 }
360 default: 360 default:
361 ADD_FAILURE(); 361 ADD_FAILURE();
362 return NULL; 362 return nullptr;
363 } 363 }
364 const base::FilePath sub_dir = base::FilePath().AppendASCII(name); 364 const base::FilePath sub_dir = base::FilePath().AppendASCII(name);
365 base::FilePath extension_dir; 365 base::FilePath extension_dir;
366 if (!base::PathExists(base_dir) && 366 if (!base::PathExists(base_dir) &&
367 !base::CreateDirectory(base_dir)) { 367 !base::CreateDirectory(base_dir)) {
368 ADD_FAILURE(); 368 ADD_FAILURE();
369 return NULL; 369 return nullptr;
370 } 370 }
371 if (!base::CreateTemporaryDirInDir(base_dir, sub_dir.value(), 371 if (!base::CreateTemporaryDirInDir(base_dir, sub_dir.value(),
372 &extension_dir)) { 372 &extension_dir)) {
373 ADD_FAILURE(); 373 ADD_FAILURE();
374 return NULL; 374 return nullptr;
375 } 375 }
376 std::string error; 376 std::string error;
377 scoped_refptr<Extension> extension = 377 scoped_refptr<Extension> extension =
378 Extension::Create(extension_dir, Manifest::INTERNAL, source, 378 Extension::Create(extension_dir, Manifest::INTERNAL, source,
379 Extension::NO_FLAGS, &error); 379 Extension::NO_FLAGS, &error);
380 if (!error.empty()) { 380 if (!error.empty()) {
381 ADD_FAILURE() << error; 381 ADD_FAILURE() << error;
382 return NULL; 382 return nullptr;
383 } 383 }
384 if (!extension.get()) { 384 if (!extension.get()) {
385 ADD_FAILURE(); 385 ADD_FAILURE();
386 return NULL; 386 return nullptr;
387 } 387 }
388 if (extension->name() != name) { 388 if (extension->name() != name) {
389 EXPECT_EQ(name, extension->name()); 389 EXPECT_EQ(name, extension->name());
390 return NULL; 390 return nullptr;
391 } 391 }
392 if (extension->GetType() != type) { 392 if (extension->GetType() != type) {
393 EXPECT_EQ(type, extension->GetType()); 393 EXPECT_EQ(type, extension->GetType());
394 return NULL; 394 return nullptr;
395 } 395 }
396 return extension; 396 return extension;
397 } 397 }
398 398
399 } // namespace 399 } // namespace
400 400
401 scoped_refptr<Extension> SyncExtensionHelper::GetExtension( 401 scoped_refptr<Extension> SyncExtensionHelper::GetExtension(
402 Profile* profile, const std::string& name, Manifest::Type type) { 402 Profile* profile, const std::string& name, Manifest::Type type) {
403 if (name.empty()) { 403 if (name.empty()) {
404 ADD_FAILURE(); 404 ADD_FAILURE();
405 return NULL; 405 return nullptr;
406 } 406 }
407 ProfileExtensionNameMap::iterator it = profile_extensions_.find(profile); 407 ProfileExtensionNameMap::iterator it = profile_extensions_.find(profile);
408 if (it == profile_extensions_.end()) { 408 if (it == profile_extensions_.end()) {
409 ADD_FAILURE(); 409 ADD_FAILURE();
410 return NULL; 410 return nullptr;
411 } 411 }
412 ExtensionNameMap::const_iterator it2 = it->second.find(name); 412 ExtensionNameMap::const_iterator it2 = it->second.find(name);
413 if (it2 != it->second.end()) { 413 if (it2 != it->second.end()) {
414 return it2->second; 414 return it2->second;
415 } 415 }
416 416
417 scoped_refptr<Extension> extension = 417 scoped_refptr<Extension> extension =
418 CreateExtension(extensions::ExtensionSystem::Get(profile) 418 CreateExtension(extensions::ExtensionSystem::Get(profile)
419 ->extension_service() 419 ->extension_service()
420 ->install_directory(), 420 ->install_directory(),
421 name, 421 name,
422 type); 422 type);
423 if (!extension.get()) { 423 if (!extension.get()) {
424 ADD_FAILURE(); 424 ADD_FAILURE();
425 return NULL; 425 return nullptr;
426 } 426 }
427 const std::string& expected_id = crx_file::id_util::GenerateId(name); 427 const std::string& expected_id = crx_file::id_util::GenerateId(name);
428 if (extension->id() != expected_id) { 428 if (extension->id() != expected_id) {
429 EXPECT_EQ(expected_id, extension->id()); 429 EXPECT_EQ(expected_id, extension->id());
430 return NULL; 430 return nullptr;
431 } 431 }
432 DVLOG(2) << "created extension with name = " 432 DVLOG(2) << "created extension with name = "
433 << name << ", id = " << expected_id; 433 << name << ", id = " << expected_id;
434 (it->second)[name] = extension; 434 (it->second)[name] = extension;
435 id_to_name_[expected_id] = name; 435 id_to_name_[expected_id] = name;
436 id_to_type_[expected_id] = type; 436 id_to_type_[expected_id] = type;
437 return extension; 437 return extension;
438 } 438 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_datatype_helper.cc ('k') | chrome/browser/sync/test/integration/sync_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698