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 <leveldb/db.h> | 7 #include <leveldb/db.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 // m: prefix for filesystem metadata db keys, version and largest_changestamp. | 25 // m: prefix for filesystem metadata db keys, version and largest_changestamp. |
26 // r: prefix for resource id db keys. | 26 // r: prefix for resource id db keys. |
27 const char kDBKeyLargestChangestamp[] = "m:largest_changestamp"; | 27 const char kDBKeyLargestChangestamp[] = "m:largest_changestamp"; |
28 const char kDBKeyVersion[] = "m:version"; | 28 const char kDBKeyVersion[] = "m:version"; |
29 const char kDBKeyResourceIdPrefix[] = "r:"; | 29 const char kDBKeyResourceIdPrefix[] = "r:"; |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 EntryInfoResult::EntryInfoResult() : error(GDATA_FILE_ERROR_FAILED) { | 33 EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) { |
34 } | 34 } |
35 | 35 |
36 EntryInfoResult::~EntryInfoResult() { | 36 EntryInfoResult::~EntryInfoResult() { |
37 } | 37 } |
38 | 38 |
39 EntryInfoPairResult::EntryInfoPairResult() { | 39 EntryInfoPairResult::EntryInfoPairResult() { |
40 } | 40 } |
41 | 41 |
42 EntryInfoPairResult::~EntryInfoPairResult() { | 42 EntryInfoPairResult::~EntryInfoPairResult() { |
43 } | 43 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 DriveDirectory* directory, | 223 DriveDirectory* directory, |
224 DriveEntry* new_entry, | 224 DriveEntry* new_entry, |
225 const FileMoveCallback& callback) { | 225 const FileMoveCallback& callback) { |
226 DCHECK(directory); | 226 DCHECK(directory); |
227 DCHECK(new_entry); | 227 DCHECK(new_entry); |
228 DCHECK(!callback.is_null()); | 228 DCHECK(!callback.is_null()); |
229 | 229 |
230 directory->AddEntry(new_entry); | 230 directory->AddEntry(new_entry); |
231 DVLOG(1) << "AddEntryToDirectory " << new_entry->GetFilePath().value(); | 231 DVLOG(1) << "AddEntryToDirectory " << new_entry->GetFilePath().value(); |
232 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 232 base::MessageLoopProxy::current()->PostTask(FROM_HERE, |
233 base::Bind(callback, GDATA_FILE_OK, new_entry->GetFilePath())); | 233 base::Bind(callback, DRIVE_FILE_OK, new_entry->GetFilePath())); |
234 } | 234 } |
235 | 235 |
236 void DriveResourceMetadata::MoveEntryToDirectory( | 236 void DriveResourceMetadata::MoveEntryToDirectory( |
237 const FilePath& directory_path, | 237 const FilePath& directory_path, |
238 DriveEntry* entry, | 238 DriveEntry* entry, |
239 const FileMoveCallback& callback) { | 239 const FileMoveCallback& callback) { |
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
241 DCHECK(entry); | 241 DCHECK(entry); |
242 DCHECK(!callback.is_null()); | 242 DCHECK(!callback.is_null()); |
243 | 243 |
244 if (entry->parent()) | 244 if (entry->parent()) |
245 entry->parent()->RemoveChild(entry); | 245 entry->parent()->RemoveChild(entry); |
246 | 246 |
247 DriveEntry* destination = FindEntryByPathSync(directory_path); | 247 DriveEntry* destination = FindEntryByPathSync(directory_path); |
248 FilePath moved_file_path; | 248 FilePath moved_file_path; |
249 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 249 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
250 if (!destination) { | 250 if (!destination) { |
251 error = GDATA_FILE_ERROR_NOT_FOUND; | 251 error = DRIVE_FILE_ERROR_NOT_FOUND; |
252 } else if (!destination->AsDriveDirectory()) { | 252 } else if (!destination->AsDriveDirectory()) { |
253 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY; | 253 error = DRIVE_FILE_ERROR_NOT_A_DIRECTORY; |
254 } else { | 254 } else { |
255 destination->AsDriveDirectory()->AddEntry(entry); | 255 destination->AsDriveDirectory()->AddEntry(entry); |
256 moved_file_path = entry->GetFilePath(); | 256 moved_file_path = entry->GetFilePath(); |
257 error = GDATA_FILE_OK; | 257 error = DRIVE_FILE_OK; |
258 } | 258 } |
259 DVLOG(1) << "MoveEntryToDirectory " << moved_file_path.value(); | 259 DVLOG(1) << "MoveEntryToDirectory " << moved_file_path.value(); |
260 base::MessageLoopProxy::current()->PostTask( | 260 base::MessageLoopProxy::current()->PostTask( |
261 FROM_HERE, base::Bind(callback, error, moved_file_path)); | 261 FROM_HERE, base::Bind(callback, error, moved_file_path)); |
262 } | 262 } |
263 | 263 |
264 void DriveResourceMetadata::RemoveEntryFromParent( | 264 void DriveResourceMetadata::RemoveEntryFromParent( |
265 DriveEntry* entry, | 265 DriveEntry* entry, |
266 const FileMoveCallback& callback) { | 266 const FileMoveCallback& callback) { |
267 DriveDirectory* parent = entry->parent(); | 267 DriveDirectory* parent = entry->parent(); |
268 DCHECK(parent); | 268 DCHECK(parent); |
269 DCHECK(!callback.is_null()); | 269 DCHECK(!callback.is_null()); |
270 DVLOG(1) << "RemoveEntryFromParent " << entry->GetFilePath().value(); | 270 DVLOG(1) << "RemoveEntryFromParent " << entry->GetFilePath().value(); |
271 | 271 |
272 parent->RemoveEntry(entry); | 272 parent->RemoveEntry(entry); |
273 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 273 base::MessageLoopProxy::current()->PostTask(FROM_HERE, |
274 base::Bind(callback, GDATA_FILE_OK, parent->GetFilePath())); | 274 base::Bind(callback, DRIVE_FILE_OK, parent->GetFilePath())); |
275 } | 275 } |
276 | 276 |
277 void DriveResourceMetadata::AddEntryToResourceMap(DriveEntry* entry) { | 277 void DriveResourceMetadata::AddEntryToResourceMap(DriveEntry* entry) { |
278 DVLOG(1) << "AddEntryToResourceMap " << entry->resource_id(); | 278 DVLOG(1) << "AddEntryToResourceMap " << entry->resource_id(); |
279 DCHECK(!entry->resource_id().empty()); | 279 DCHECK(!entry->resource_id().empty()); |
280 std::pair<ResourceMap::iterator, bool> ret = | 280 std::pair<ResourceMap::iterator, bool> ret = |
281 resource_map_.insert(std::make_pair(entry->resource_id(), entry)); | 281 resource_map_.insert(std::make_pair(entry->resource_id(), entry)); |
282 DCHECK(ret.second); // resource_id did not previously exist in the map. | 282 DCHECK(ret.second); // resource_id did not previously exist in the map. |
283 } | 283 } |
284 | 284 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 callback.Run(entry); | 329 callback.Run(entry); |
330 } | 330 } |
331 | 331 |
332 void DriveResourceMetadata::GetEntryInfoByResourceId( | 332 void DriveResourceMetadata::GetEntryInfoByResourceId( |
333 const std::string& resource_id, | 333 const std::string& resource_id, |
334 const GetEntryInfoWithFilePathCallback& callback) { | 334 const GetEntryInfoWithFilePathCallback& callback) { |
335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
336 DCHECK(!callback.is_null()); | 336 DCHECK(!callback.is_null()); |
337 | 337 |
338 scoped_ptr<DriveEntryProto> entry_proto; | 338 scoped_ptr<DriveEntryProto> entry_proto; |
339 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 339 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
340 FilePath drive_file_path; | 340 FilePath drive_file_path; |
341 | 341 |
342 DriveEntry* entry = GetEntryByResourceId(resource_id); | 342 DriveEntry* entry = GetEntryByResourceId(resource_id); |
343 if (entry) { | 343 if (entry) { |
344 entry_proto.reset(new DriveEntryProto); | 344 entry_proto.reset(new DriveEntryProto); |
345 entry->ToProtoFull(entry_proto.get()); | 345 entry->ToProtoFull(entry_proto.get()); |
346 error = GDATA_FILE_OK; | 346 error = DRIVE_FILE_OK; |
347 drive_file_path = entry->GetFilePath(); | 347 drive_file_path = entry->GetFilePath(); |
348 } else { | 348 } else { |
349 error = GDATA_FILE_ERROR_NOT_FOUND; | 349 error = DRIVE_FILE_ERROR_NOT_FOUND; |
350 } | 350 } |
351 | 351 |
352 base::MessageLoopProxy::current()->PostTask( | 352 base::MessageLoopProxy::current()->PostTask( |
353 FROM_HERE, | 353 FROM_HERE, |
354 base::Bind(callback, | 354 base::Bind(callback, |
355 error, | 355 error, |
356 drive_file_path, | 356 drive_file_path, |
357 base::Passed(&entry_proto))); | 357 base::Passed(&entry_proto))); |
358 } | 358 } |
359 | 359 |
360 void DriveResourceMetadata::GetEntryInfoByPath( | 360 void DriveResourceMetadata::GetEntryInfoByPath( |
361 const FilePath& path, | 361 const FilePath& path, |
362 const GetEntryInfoCallback& callback) { | 362 const GetEntryInfoCallback& callback) { |
363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
364 DCHECK(!callback.is_null()); | 364 DCHECK(!callback.is_null()); |
365 | 365 |
366 scoped_ptr<DriveEntryProto> entry_proto; | 366 scoped_ptr<DriveEntryProto> entry_proto; |
367 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 367 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
368 | 368 |
369 DriveEntry* entry = FindEntryByPathSync(path); | 369 DriveEntry* entry = FindEntryByPathSync(path); |
370 if (entry) { | 370 if (entry) { |
371 entry_proto.reset(new DriveEntryProto); | 371 entry_proto.reset(new DriveEntryProto); |
372 entry->ToProtoFull(entry_proto.get()); | 372 entry->ToProtoFull(entry_proto.get()); |
373 error = GDATA_FILE_OK; | 373 error = DRIVE_FILE_OK; |
374 } else { | 374 } else { |
375 error = GDATA_FILE_ERROR_NOT_FOUND; | 375 error = DRIVE_FILE_ERROR_NOT_FOUND; |
376 } | 376 } |
377 | 377 |
378 base::MessageLoopProxy::current()->PostTask( | 378 base::MessageLoopProxy::current()->PostTask( |
379 FROM_HERE, | 379 FROM_HERE, |
380 base::Bind(callback, error, base::Passed(&entry_proto))); | 380 base::Bind(callback, error, base::Passed(&entry_proto))); |
381 } | 381 } |
382 | 382 |
383 void DriveResourceMetadata::ReadDirectoryByPath( | 383 void DriveResourceMetadata::ReadDirectoryByPath( |
384 const FilePath& path, | 384 const FilePath& path, |
385 const ReadDirectoryCallback& callback) { | 385 const ReadDirectoryCallback& callback) { |
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
387 DCHECK(!callback.is_null()); | 387 DCHECK(!callback.is_null()); |
388 | 388 |
389 scoped_ptr<DriveEntryProtoVector> entries; | 389 scoped_ptr<DriveEntryProtoVector> entries; |
390 GDataFileError error = GDATA_FILE_ERROR_FAILED; | 390 DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
391 | 391 |
392 DriveEntry* entry = FindEntryByPathSync(path); | 392 DriveEntry* entry = FindEntryByPathSync(path); |
393 if (entry && entry->AsDriveDirectory()) { | 393 if (entry && entry->AsDriveDirectory()) { |
394 entries = entry->AsDriveDirectory()->ToProtoVector(); | 394 entries = entry->AsDriveDirectory()->ToProtoVector(); |
395 error = GDATA_FILE_OK; | 395 error = DRIVE_FILE_OK; |
396 } else if (entry && !entry->AsDriveDirectory()) { | 396 } else if (entry && !entry->AsDriveDirectory()) { |
397 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY; | 397 error = DRIVE_FILE_ERROR_NOT_A_DIRECTORY; |
398 } else { | 398 } else { |
399 error = GDATA_FILE_ERROR_NOT_FOUND; | 399 error = DRIVE_FILE_ERROR_NOT_FOUND; |
400 } | 400 } |
401 | 401 |
402 base::MessageLoopProxy::current()->PostTask( | 402 base::MessageLoopProxy::current()->PostTask( |
403 FROM_HERE, | 403 FROM_HERE, |
404 base::Bind(callback, error, base::Passed(&entries))); | 404 base::Bind(callback, error, base::Passed(&entries))); |
405 } | 405 } |
406 | 406 |
407 void DriveResourceMetadata::GetEntryInfoPairByPaths( | 407 void DriveResourceMetadata::GetEntryInfoPairByPaths( |
408 const FilePath& first_path, | 408 const FilePath& first_path, |
409 const FilePath& second_path, | 409 const FilePath& second_path, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 459 } |
460 | 460 |
461 // static | 461 // static |
462 void DriveResourceMetadata::RefreshDirectoryInternal( | 462 void DriveResourceMetadata::RefreshDirectoryInternal( |
463 const ResourceMap& file_map, | 463 const ResourceMap& file_map, |
464 const FileMoveCallback& callback, | 464 const FileMoveCallback& callback, |
465 DriveEntry* directory_entry) { | 465 DriveEntry* directory_entry) { |
466 DCHECK(!callback.is_null()); | 466 DCHECK(!callback.is_null()); |
467 | 467 |
468 if (!directory_entry) { | 468 if (!directory_entry) { |
469 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, FilePath()); | 469 callback.Run(DRIVE_FILE_ERROR_NOT_FOUND, FilePath()); |
470 return; | 470 return; |
471 } | 471 } |
472 | 472 |
473 DriveDirectory* directory = directory_entry->AsDriveDirectory(); | 473 DriveDirectory* directory = directory_entry->AsDriveDirectory(); |
474 if (!directory) { | 474 if (!directory) { |
475 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY, FilePath()); | 475 callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY, FilePath()); |
476 return; | 476 return; |
477 } | 477 } |
478 | 478 |
479 DVLOG(1) << "RefreshDirectoryInternal"; | 479 DVLOG(1) << "RefreshDirectoryInternal"; |
480 directory->RemoveChildFiles(); | 480 directory->RemoveChildFiles(); |
481 // Add files from file_map. | 481 // Add files from file_map. |
482 for (ResourceMap::const_iterator it = file_map.begin(); | 482 for (ResourceMap::const_iterator it = file_map.begin(); |
483 it != file_map.end(); ++it) { | 483 it != file_map.end(); ++it) { |
484 scoped_ptr<DriveEntry> entry(it->second); | 484 scoped_ptr<DriveEntry> entry(it->second); |
485 // Skip if it's not a file (i.e. directory). | 485 // Skip if it's not a file (i.e. directory). |
486 if (!entry->AsDriveFile()) | 486 if (!entry->AsDriveFile()) |
487 continue; | 487 continue; |
488 directory->AddEntry(entry.release()); | 488 directory->AddEntry(entry.release()); |
489 } | 489 } |
490 | 490 |
491 callback.Run(GDATA_FILE_OK, directory->GetFilePath()); | 491 callback.Run(DRIVE_FILE_OK, directory->GetFilePath()); |
492 } | 492 } |
493 | 493 |
494 void DriveResourceMetadata::InitFromDB( | 494 void DriveResourceMetadata::InitFromDB( |
495 const FilePath& db_path, | 495 const FilePath& db_path, |
496 base::SequencedTaskRunner* blocking_task_runner, | 496 base::SequencedTaskRunner* blocking_task_runner, |
497 const FileOperationCallback& callback) { | 497 const FileOperationCallback& callback) { |
498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
499 DCHECK(!db_path.empty()); | 499 DCHECK(!db_path.empty()); |
500 DCHECK(blocking_task_runner); | 500 DCHECK(blocking_task_runner); |
501 | 501 |
502 if (resource_metadata_db_.get()) { | 502 if (resource_metadata_db_.get()) { |
503 if (!callback.is_null()) | 503 if (!callback.is_null()) |
504 callback.Run(GDATA_FILE_ERROR_FAILED); | 504 callback.Run(DRIVE_FILE_ERROR_FAILED); |
505 return; | 505 return; |
506 } | 506 } |
507 | 507 |
508 blocking_task_runner_ = blocking_task_runner; | 508 blocking_task_runner_ = blocking_task_runner; |
509 | 509 |
510 DVLOG(1) << "InitFromDB " << db_path.value(); | 510 DVLOG(1) << "InitFromDB " << db_path.value(); |
511 | 511 |
512 CreateDBParams* create_params = | 512 CreateDBParams* create_params = |
513 new CreateDBParams(db_path, blocking_task_runner); | 513 new CreateDBParams(db_path, blocking_task_runner); |
514 blocking_task_runner_->PostTaskAndReply( | 514 blocking_task_runner_->PostTaskAndReply( |
(...skipping 11 matching lines...) Expand all Loading... |
526 const FileOperationCallback& callback) { | 526 const FileOperationCallback& callback) { |
527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
528 DCHECK(create_params); | 528 DCHECK(create_params); |
529 DCHECK(!resource_metadata_db_.get()); | 529 DCHECK(!resource_metadata_db_.get()); |
530 | 530 |
531 SerializedMap* serialized_resources = &create_params->serialized_resources; | 531 SerializedMap* serialized_resources = &create_params->serialized_resources; |
532 resource_metadata_db_ = create_params->db.Pass(); | 532 resource_metadata_db_ = create_params->db.Pass(); |
533 if (serialized_resources->empty()) { | 533 if (serialized_resources->empty()) { |
534 origin_ = INITIALIZING; | 534 origin_ = INITIALIZING; |
535 if (!callback.is_null()) | 535 if (!callback.is_null()) |
536 callback.Run(GDATA_FILE_ERROR_NOT_FOUND); | 536 callback.Run(DRIVE_FILE_ERROR_NOT_FOUND); |
537 return; | 537 return; |
538 } | 538 } |
539 | 539 |
540 ClearRoot(); | 540 ClearRoot(); |
541 | 541 |
542 // Version check. | 542 // Version check. |
543 int32 version = 0; | 543 int32 version = 0; |
544 SerializedMap::iterator iter = serialized_resources->find(kDBKeyVersion); | 544 SerializedMap::iterator iter = serialized_resources->find(kDBKeyVersion); |
545 if (iter == serialized_resources->end() || | 545 if (iter == serialized_resources->end() || |
546 !base::StringToInt(iter->second, &version) || | 546 !base::StringToInt(iter->second, &version) || |
547 version != kProtoVersion) { | 547 version != kProtoVersion) { |
548 if (!callback.is_null()) | 548 if (!callback.is_null()) |
549 callback.Run(GDATA_FILE_ERROR_FAILED); | 549 callback.Run(DRIVE_FILE_ERROR_FAILED); |
550 return; | 550 return; |
551 } | 551 } |
552 serialized_resources->erase(iter); | 552 serialized_resources->erase(iter); |
553 | 553 |
554 // Get the largest changestamp. | 554 // Get the largest changestamp. |
555 iter = serialized_resources->find(kDBKeyLargestChangestamp); | 555 iter = serialized_resources->find(kDBKeyLargestChangestamp); |
556 if (iter == serialized_resources->end() || | 556 if (iter == serialized_resources->end() || |
557 !base::StringToInt64(iter->second, &largest_changestamp_)) { | 557 !base::StringToInt64(iter->second, &largest_changestamp_)) { |
558 NOTREACHED() << "Could not find/parse largest_changestamp"; | 558 NOTREACHED() << "Could not find/parse largest_changestamp"; |
559 if (!callback.is_null()) | 559 if (!callback.is_null()) |
560 callback.Run(GDATA_FILE_ERROR_FAILED); | 560 callback.Run(DRIVE_FILE_ERROR_FAILED); |
561 return; | 561 return; |
562 } else { | 562 } else { |
563 DVLOG(1) << "InitResourceMap largest_changestamp_" << largest_changestamp_; | 563 DVLOG(1) << "InitResourceMap largest_changestamp_" << largest_changestamp_; |
564 serialized_resources->erase(iter); | 564 serialized_resources->erase(iter); |
565 } | 565 } |
566 | 566 |
567 ResourceMap resource_map; | 567 ResourceMap resource_map; |
568 for (SerializedMap::const_iterator iter = serialized_resources->begin(); | 568 for (SerializedMap::const_iterator iter = serialized_resources->begin(); |
569 iter != serialized_resources->end(); ++iter) { | 569 iter != serialized_resources->end(); ++iter) { |
570 if (iter->first.find(kDBKeyResourceIdPrefix) != 0) { | 570 if (iter->first.find(kDBKeyResourceIdPrefix) != 0) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 } | 610 } |
611 | 611 |
612 DCHECK(root_.get()); | 612 DCHECK(root_.get()); |
613 DCHECK_EQ(resource_map.size(), resource_map_.size()); | 613 DCHECK_EQ(resource_map.size(), resource_map_.size()); |
614 DCHECK_EQ(resource_map.size(), serialized_resources->size()); | 614 DCHECK_EQ(resource_map.size(), serialized_resources->size()); |
615 | 615 |
616 origin_ = FROM_CACHE; | 616 origin_ = FROM_CACHE; |
617 | 617 |
618 if (!callback.is_null()) | 618 if (!callback.is_null()) |
619 callback.Run(GDATA_FILE_OK); | 619 callback.Run(DRIVE_FILE_OK); |
620 } | 620 } |
621 | 621 |
622 void DriveResourceMetadata::SaveToDB() { | 622 void DriveResourceMetadata::SaveToDB() { |
623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
624 | 624 |
625 if (!blocking_task_runner_ || !resource_metadata_db_.get()) { | 625 if (!blocking_task_runner_ || !resource_metadata_db_.get()) { |
626 NOTREACHED(); | 626 NOTREACHED(); |
627 return; | 627 return; |
628 } | 628 } |
629 | 629 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 file->FromProto(entry_proto); | 707 file->FromProto(entry_proto); |
708 entry.reset(file.release()); | 708 entry.reset(file.release()); |
709 } | 709 } |
710 return entry.Pass(); | 710 return entry.Pass(); |
711 } | 711 } |
712 | 712 |
713 void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetFirst( | 713 void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetFirst( |
714 const FilePath& first_path, | 714 const FilePath& first_path, |
715 const FilePath& second_path, | 715 const FilePath& second_path, |
716 const GetEntryInfoPairCallback& callback, | 716 const GetEntryInfoPairCallback& callback, |
717 GDataFileError error, | 717 DriveFileError error, |
718 scoped_ptr<DriveEntryProto> entry_proto) { | 718 scoped_ptr<DriveEntryProto> entry_proto) { |
719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
720 DCHECK(!callback.is_null()); | 720 DCHECK(!callback.is_null()); |
721 | 721 |
722 scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult); | 722 scoped_ptr<EntryInfoPairResult> result(new EntryInfoPairResult); |
723 result->first.path = first_path; | 723 result->first.path = first_path; |
724 result->first.error = error; | 724 result->first.error = error; |
725 result->first.proto = entry_proto.Pass(); | 725 result->first.proto = entry_proto.Pass(); |
726 | 726 |
727 // If the first one is not found, don't continue. | 727 // If the first one is not found, don't continue. |
728 if (error != GDATA_FILE_OK) { | 728 if (error != DRIVE_FILE_OK) { |
729 callback.Run(result.Pass()); | 729 callback.Run(result.Pass()); |
730 return; | 730 return; |
731 } | 731 } |
732 | 732 |
733 // Get the second entry. | 733 // Get the second entry. |
734 GetEntryInfoByPath( | 734 GetEntryInfoByPath( |
735 second_path, | 735 second_path, |
736 base::Bind(&DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond, | 736 base::Bind(&DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond, |
737 weak_ptr_factory_.GetWeakPtr(), | 737 weak_ptr_factory_.GetWeakPtr(), |
738 second_path, | 738 second_path, |
739 callback, | 739 callback, |
740 base::Passed(&result))); | 740 base::Passed(&result))); |
741 } | 741 } |
742 | 742 |
743 void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond( | 743 void DriveResourceMetadata::GetEntryInfoPairByPathsAfterGetSecond( |
744 const FilePath& second_path, | 744 const FilePath& second_path, |
745 const GetEntryInfoPairCallback& callback, | 745 const GetEntryInfoPairCallback& callback, |
746 scoped_ptr<EntryInfoPairResult> result, | 746 scoped_ptr<EntryInfoPairResult> result, |
747 GDataFileError error, | 747 DriveFileError error, |
748 scoped_ptr<DriveEntryProto> entry_proto) { | 748 scoped_ptr<DriveEntryProto> entry_proto) { |
749 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 749 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
750 DCHECK(!callback.is_null()); | 750 DCHECK(!callback.is_null()); |
751 DCHECK(result.get()); | 751 DCHECK(result.get()); |
752 | 752 |
753 result->second.path = second_path; | 753 result->second.path = second_path; |
754 result->second.error = error; | 754 result->second.error = error; |
755 result->second.proto = entry_proto.Pass(); | 755 result->second.proto = entry_proto.Pass(); |
756 | 756 |
757 callback.Run(result.Pass()); | 757 callback.Run(result.Pass()); |
758 } | 758 } |
759 | 759 |
760 } // namespace gdata | 760 } // namespace gdata |
OLD | NEW |