| OLD | NEW |
| 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/chromeos/gdata/drive_resource_metadata.h" | 5 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 16 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 17 #include "chrome/browser/chromeos/gdata/drive_cache.h" |
| 17 #include "chrome/browser/chromeos/gdata/drive_files.h" | 18 #include "chrome/browser/chromeos/gdata/drive_files.h" |
| 18 #include "chrome/browser/chromeos/gdata/gdata_cache.h" | |
| 19 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 namespace gdata { | 24 namespace gdata { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // See drive.proto for the difference between the two URLs. | 27 // See drive.proto for the difference between the two URLs. |
| 28 const char kResumableEditMediaUrl[] = "http://resumable-edit-media/"; | 28 const char kResumableEditMediaUrl[] = "http://resumable-edit-media/"; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 content::TestBrowserThread ui_thread(content::BrowserThread::UI, | 503 content::TestBrowserThread ui_thread(content::BrowserThread::UI, |
| 504 &message_loop); | 504 &message_loop); |
| 505 | 505 |
| 506 scoped_ptr<TestingProfile> profile(new TestingProfile); | 506 scoped_ptr<TestingProfile> profile(new TestingProfile); |
| 507 scoped_refptr<base::SequencedWorkerPool> pool = | 507 scoped_refptr<base::SequencedWorkerPool> pool = |
| 508 content::BrowserThread::GetBlockingPool(); | 508 content::BrowserThread::GetBlockingPool(); |
| 509 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = | 509 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = |
| 510 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 510 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
| 511 | 511 |
| 512 DriveResourceMetadata resource_metadata; | 512 DriveResourceMetadata resource_metadata; |
| 513 FilePath db_path(GDataCache::GetCacheRootPath(profile.get()). | 513 FilePath db_path(DriveCache::GetCacheRootPath(profile.get()). |
| 514 AppendASCII("meta").AppendASCII("resource_metadata.db")); | 514 AppendASCII("meta").AppendASCII("resource_metadata.db")); |
| 515 // InitFromDB should fail with GDATA_FILE_ERROR_NOT_FOUND since the db | 515 // InitFromDB should fail with GDATA_FILE_ERROR_NOT_FOUND since the db |
| 516 // doesn't exist. | 516 // doesn't exist. |
| 517 resource_metadata.InitFromDB(db_path, blocking_task_runner, | 517 resource_metadata.InitFromDB(db_path, blocking_task_runner, |
| 518 base::Bind(&InitFromDBCallback, GDATA_FILE_ERROR_NOT_FOUND)); | 518 base::Bind(&InitFromDBCallback, GDATA_FILE_ERROR_NOT_FOUND)); |
| 519 test_util::RunBlockingPoolTask(); | 519 test_util::RunBlockingPoolTask(); |
| 520 InitDirectoryService(&resource_metadata); | 520 InitDirectoryService(&resource_metadata); |
| 521 | 521 |
| 522 // Write the filesystem to db. | 522 // Write the filesystem to db. |
| 523 resource_metadata.SaveToDB(); | 523 resource_metadata.SaveToDB(); |
| 524 test_util::RunBlockingPoolTask(); | 524 test_util::RunBlockingPoolTask(); |
| 525 | 525 |
| 526 DriveResourceMetadata resource_metadata2; | 526 DriveResourceMetadata resource_metadata2; |
| 527 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. | 527 // InitFromDB should succeed with GDATA_FILE_OK as the db now exists. |
| 528 resource_metadata2.InitFromDB(db_path, blocking_task_runner, | 528 resource_metadata2.InitFromDB(db_path, blocking_task_runner, |
| 529 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); | 529 base::Bind(&InitFromDBCallback, GDATA_FILE_OK)); |
| 530 test_util::RunBlockingPoolTask(); | 530 test_util::RunBlockingPoolTask(); |
| 531 | 531 |
| 532 VerifyDirectoryService(&resource_metadata2); | 532 VerifyDirectoryService(&resource_metadata2); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace gdata | 535 } // namespace gdata |
| OLD | NEW |