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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_manager_browsertest_base.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/file_manager/file_manager_browsertest_base.h" 5 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <deque> 9 #include <deque>
10 10
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 DriveTestVolume() : TestVolume("drive"), integration_service_(NULL) {} 369 DriveTestVolume() : TestVolume("drive"), integration_service_(NULL) {}
370 ~DriveTestVolume() override {} 370 ~DriveTestVolume() override {}
371 371
372 void CreateEntry(const TestEntryInfo& entry) { 372 void CreateEntry(const TestEntryInfo& entry) {
373 const base::FilePath path = 373 const base::FilePath path =
374 base::FilePath::FromUTF8Unsafe(entry.target_path); 374 base::FilePath::FromUTF8Unsafe(entry.target_path);
375 const std::string target_name = path.BaseName().AsUTF8Unsafe(); 375 const std::string target_name = path.BaseName().AsUTF8Unsafe();
376 376
377 // Obtain the parent entry. 377 // Obtain the parent entry.
378 drive::FileError error = drive::FILE_ERROR_OK; 378 drive::FileError error = drive::FILE_ERROR_OK;
379 scoped_ptr<drive::ResourceEntry> parent_entry(new drive::ResourceEntry); 379 std::unique_ptr<drive::ResourceEntry> parent_entry(
380 new drive::ResourceEntry);
380 integration_service_->file_system()->GetResourceEntry( 381 integration_service_->file_system()->GetResourceEntry(
381 drive::util::GetDriveMyDriveRootPath().Append(path).DirName(), 382 drive::util::GetDriveMyDriveRootPath().Append(path).DirName(),
382 google_apis::test_util::CreateCopyResultCallback(&error, 383 google_apis::test_util::CreateCopyResultCallback(&error,
383 &parent_entry)); 384 &parent_entry));
384 content::RunAllBlockingPoolTasksUntilIdle(); 385 content::RunAllBlockingPoolTasksUntilIdle();
385 ASSERT_EQ(drive::FILE_ERROR_OK, error); 386 ASSERT_EQ(drive::FILE_ERROR_OK, error);
386 ASSERT_TRUE(parent_entry); 387 ASSERT_TRUE(parent_entry);
387 388
388 switch (entry.type) { 389 switch (entry.type) {
389 case FILE: 390 case FILE:
390 CreateFile(entry.source_file_name, parent_entry->resource_id(), 391 CreateFile(entry.source_file_name, parent_entry->resource_id(),
391 target_name, entry.mime_type, entry.shared_option == SHARED, 392 target_name, entry.mime_type, entry.shared_option == SHARED,
392 entry.last_modified_time); 393 entry.last_modified_time);
393 break; 394 break;
394 case DIRECTORY: 395 case DIRECTORY:
395 CreateDirectory(parent_entry->resource_id(), target_name, 396 CreateDirectory(parent_entry->resource_id(), target_name,
396 entry.last_modified_time); 397 entry.last_modified_time);
397 break; 398 break;
398 } 399 }
399 } 400 }
400 401
401 // Creates an empty directory with the given |name| and |modification_time|. 402 // Creates an empty directory with the given |name| and |modification_time|.
402 void CreateDirectory(const std::string& parent_id, 403 void CreateDirectory(const std::string& parent_id,
403 const std::string& target_name, 404 const std::string& target_name,
404 const base::Time& modification_time) { 405 const base::Time& modification_time) {
405 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 406 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
406 scoped_ptr<google_apis::FileResource> entry; 407 std::unique_ptr<google_apis::FileResource> entry;
407 fake_drive_service_->AddNewDirectory( 408 fake_drive_service_->AddNewDirectory(
408 parent_id, target_name, drive::AddNewDirectoryOptions(), 409 parent_id, target_name, drive::AddNewDirectoryOptions(),
409 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 410 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
410 base::MessageLoop::current()->RunUntilIdle(); 411 base::MessageLoop::current()->RunUntilIdle();
411 ASSERT_EQ(google_apis::HTTP_CREATED, error); 412 ASSERT_EQ(google_apis::HTTP_CREATED, error);
412 ASSERT_TRUE(entry); 413 ASSERT_TRUE(entry);
413 414
414 fake_drive_service_->SetLastModifiedTime( 415 fake_drive_service_->SetLastModifiedTime(
415 entry->file_id(), modification_time, 416 entry->file_id(), modification_time,
416 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 417 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
(...skipping 12 matching lines...) Expand all
429 bool shared_with_me, 430 bool shared_with_me,
430 const base::Time& modification_time) { 431 const base::Time& modification_time) {
431 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 432 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
432 433
433 std::string content_data; 434 std::string content_data;
434 if (!source_file_name.empty()) { 435 if (!source_file_name.empty()) {
435 base::FilePath source_file_path = GetTestFilePath(source_file_name); 436 base::FilePath source_file_path = GetTestFilePath(source_file_name);
436 ASSERT_TRUE(base::ReadFileToString(source_file_path, &content_data)); 437 ASSERT_TRUE(base::ReadFileToString(source_file_path, &content_data));
437 } 438 }
438 439
439 scoped_ptr<google_apis::FileResource> entry; 440 std::unique_ptr<google_apis::FileResource> entry;
440 fake_drive_service_->AddNewFile( 441 fake_drive_service_->AddNewFile(
441 mime_type, content_data, parent_id, target_name, shared_with_me, 442 mime_type, content_data, parent_id, target_name, shared_with_me,
442 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 443 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
443 base::MessageLoop::current()->RunUntilIdle(); 444 base::MessageLoop::current()->RunUntilIdle();
444 ASSERT_EQ(google_apis::HTTP_CREATED, error); 445 ASSERT_EQ(google_apis::HTTP_CREATED, error);
445 ASSERT_TRUE(entry); 446 ASSERT_TRUE(entry);
446 447
447 fake_drive_service_->SetLastModifiedTime( 448 fake_drive_service_->SetLastModifiedTime(
448 entry->file_id(), modification_time, 449 entry->file_id(), modification_time,
449 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 450 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_PASSED) { 570 if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_PASSED) {
570 // Test succeed. 571 // Test succeed.
571 break; 572 break;
572 } else if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_FAILED) { 573 } else if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_FAILED) {
573 // Test failed. 574 // Test failed.
574 ADD_FAILURE() << entry.message; 575 ADD_FAILURE() << entry.message;
575 break; 576 break;
576 } 577 }
577 578
578 // Parse the message value as JSON. 579 // Parse the message value as JSON.
579 const scoped_ptr<const base::Value> value = 580 const std::unique_ptr<const base::Value> value =
580 base::JSONReader::Read(entry.message); 581 base::JSONReader::Read(entry.message);
581 582
582 // If the message is not the expected format, just ignore it. 583 // If the message is not the expected format, just ignore it.
583 const base::DictionaryValue* message_dictionary = NULL; 584 const base::DictionaryValue* message_dictionary = NULL;
584 std::string name; 585 std::string name;
585 if (!value || !value->GetAsDictionary(&message_dictionary) || 586 if (!value || !value->GetAsDictionary(&message_dictionary) ||
586 !message_dictionary->GetString("name", &name)) 587 !message_dictionary->GetString("name", &name))
587 continue; 588 continue;
588 589
589 std::string output; 590 std::string output;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 726 }
726 727
727 drive::DriveIntegrationService* 728 drive::DriveIntegrationService*
728 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { 729 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) {
729 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); 730 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume());
730 return drive_volumes_[profile->GetOriginalProfile()] 731 return drive_volumes_[profile->GetOriginalProfile()]
731 ->CreateDriveIntegrationService(profile); 732 ->CreateDriveIntegrationService(profile);
732 } 733 }
733 734
734 } // namespace file_manager 735 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698