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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc

Issue 302003013: [SyncFS] Run V2 backend tasks as SyncTask (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 | Annotate | Revision Log
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/browser/sync_file_system/drive_backend/metadata_database_index. h" 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index. h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" 8 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h"
9 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 9 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
10 10
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void MetadataDatabaseIndex::AddToPathIndexes( 321 void MetadataDatabaseIndex::AddToPathIndexes(
322 const FileTracker& new_tracker) { 322 const FileTracker& new_tracker) {
323 int64 parent = new_tracker.parent_tracker_id(); 323 int64 parent = new_tracker.parent_tracker_id();
324 std::string title = GetTrackerTitle(new_tracker); 324 std::string title = GetTrackerTitle(new_tracker);
325 325
326 DVLOG(3) << " Add to trackers_by_parent_and_title_: " 326 DVLOG(3) << " Add to trackers_by_parent_and_title_: "
327 << parent << " " << title; 327 << parent << " " << title;
328 328
329 trackers_by_parent_and_title_[parent][title].Insert(new_tracker); 329 trackers_by_parent_and_title_[parent][title].Insert(new_tracker);
330 330
331 if (trackers_by_parent_and_title_[parent][title].size() > 1) { 331 if (trackers_by_parent_and_title_[parent][title].size() > 1 &&
332 !title.empty()) {
332 DVLOG_IF(3, !ContainsKey(multi_backing_file_paths_, 333 DVLOG_IF(3, !ContainsKey(multi_backing_file_paths_,
333 ParentIDAndTitle(parent, title))) 334 ParentIDAndTitle(parent, title)))
334 << " Add to multi_backing_file_paths_: " << parent << " " << title; 335 << " Add to multi_backing_file_paths_: " << parent << " " << title;
335 multi_backing_file_paths_.insert(ParentIDAndTitle(parent, title)); 336 multi_backing_file_paths_.insert(ParentIDAndTitle(parent, title));
336 } 337 }
337 } 338 }
338 339
339 void MetadataDatabaseIndex::UpdateInPathIndexes( 340 void MetadataDatabaseIndex::UpdateInPathIndexes(
340 const FileTracker& old_tracker, 341 const FileTracker& old_tracker,
341 const FileTracker& new_tracker) { 342 const FileTracker& new_tracker) {
(...skipping 20 matching lines...) Expand all
362 trackers_by_title->erase(found); 363 trackers_by_title->erase(found);
363 } else { 364 } else {
364 NOTREACHED(); 365 NOTREACHED();
365 } 366 }
366 367
367 DVLOG(3) << " Add to trackers_by_parent_and_title_: " 368 DVLOG(3) << " Add to trackers_by_parent_and_title_: "
368 << parent << " " << title; 369 << parent << " " << title;
369 370
370 (*trackers_by_title)[title].Insert(new_tracker); 371 (*trackers_by_title)[title].Insert(new_tracker);
371 372
372 if (trackers_by_parent_and_title_[parent][old_title].size() <= 1) { 373 if (trackers_by_parent_and_title_[parent][old_title].size() <= 1 &&
374 !old_title.empty()) {
373 DVLOG_IF(3, ContainsKey(multi_backing_file_paths_, 375 DVLOG_IF(3, ContainsKey(multi_backing_file_paths_,
374 ParentIDAndTitle(parent, title))) 376 ParentIDAndTitle(parent, old_title)))
375 << " Remove from multi_backing_file_paths_: " 377 << " Remove from multi_backing_file_paths_: "
376 << parent << " " << title; 378 << parent << " " << old_title;
377 multi_backing_file_paths_.erase(ParentIDAndTitle(parent, title)); 379 multi_backing_file_paths_.erase(ParentIDAndTitle(parent, old_title));
378 } 380 }
379 381
380 if (trackers_by_parent_and_title_[parent][title].size() > 1) { 382 if (trackers_by_parent_and_title_[parent][title].size() > 1 &&
383 !title.empty()) {
381 DVLOG_IF(3, !ContainsKey(multi_backing_file_paths_, 384 DVLOG_IF(3, !ContainsKey(multi_backing_file_paths_,
382 ParentIDAndTitle(parent, title))) 385 ParentIDAndTitle(parent, title)))
383 << " Add to multi_backing_file_paths_: " << parent << " " << title; 386 << " Add to multi_backing_file_paths_: " << parent << " " << title;
384 multi_backing_file_paths_.insert(ParentIDAndTitle(parent, title)); 387 multi_backing_file_paths_.insert(ParentIDAndTitle(parent, title));
385 } 388 }
386 389
387 return; 390 return;
388 } 391 }
389 392
390 if (old_tracker.active() && !new_tracker.active()) 393 if (old_tracker.active() && !new_tracker.active())
391 trackers_by_parent_and_title_[parent][title].Deactivate(tracker_id); 394 trackers_by_parent_and_title_[parent][title].Deactivate(tracker_id);
392 else if (!old_tracker.active() && new_tracker.active()) 395 else if (!old_tracker.active() && new_tracker.active())
393 trackers_by_parent_and_title_[parent][title].Activate(tracker_id); 396 trackers_by_parent_and_title_[parent][title].Activate(tracker_id);
394 } 397 }
395 398
396 void MetadataDatabaseIndex::RemoveFromPathIndexes( 399 void MetadataDatabaseIndex::RemoveFromPathIndexes(
397 const FileTracker& tracker) { 400 const FileTracker& tracker) {
398 int64 tracker_id = tracker.tracker_id(); 401 int64 tracker_id = tracker.tracker_id();
399 int64 parent = tracker.parent_tracker_id(); 402 int64 parent = tracker.parent_tracker_id();
400 std::string title = GetTrackerTitle(tracker); 403 std::string title = GetTrackerTitle(tracker);
401 404
402 DCHECK(ContainsKey(trackers_by_parent_and_title_, parent)); 405 DCHECK(ContainsKey(trackers_by_parent_and_title_, parent));
403 DCHECK(ContainsKey(trackers_by_parent_and_title_[parent], title)); 406 DCHECK(ContainsKey(trackers_by_parent_and_title_[parent], title));
404 407
405 DVLOG(3) << " Remove from trackers_by_parent_and_title_: " 408 DVLOG(3) << " Remove from trackers_by_parent_and_title_: "
406 << parent << " " << title; 409 << parent << " " << title;
407 410
408 trackers_by_parent_and_title_[parent][title].Erase(tracker_id); 411 trackers_by_parent_and_title_[parent][title].Erase(tracker_id);
409 412
410 if (trackers_by_parent_and_title_[parent][title].size() <= 1) { 413 if (trackers_by_parent_and_title_[parent][title].size() <= 1 &&
414 !title.empty()) {
411 DVLOG_IF(3, ContainsKey(multi_backing_file_paths_, 415 DVLOG_IF(3, ContainsKey(multi_backing_file_paths_,
412 ParentIDAndTitle(parent, title))) 416 ParentIDAndTitle(parent, title)))
413 << " Remove from multi_backing_file_paths_: " 417 << " Remove from multi_backing_file_paths_: "
414 << parent << " " << title; 418 << parent << " " << title;
415 multi_backing_file_paths_.erase(ParentIDAndTitle(parent, title)); 419 multi_backing_file_paths_.erase(ParentIDAndTitle(parent, title));
416 } 420 }
417 421
418 if (trackers_by_parent_and_title_[parent][title].empty()) { 422 if (trackers_by_parent_and_title_[parent][title].empty()) {
419 trackers_by_parent_and_title_[parent].erase(title); 423 trackers_by_parent_and_title_[parent].erase(title);
420 if (trackers_by_parent_and_title_[parent].empty()) 424 if (trackers_by_parent_and_title_[parent].empty())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 470
467 DVLOG(3) << " Remove from dirty_trackers_: " << tracker_id; 471 DVLOG(3) << " Remove from dirty_trackers_: " << tracker_id;
468 dirty_trackers_.erase(tracker_id); 472 dirty_trackers_.erase(tracker_id);
469 473
470 demoted_dirty_trackers_.erase(tracker_id); 474 demoted_dirty_trackers_.erase(tracker_id);
471 } 475 }
472 } 476 }
473 477
474 } // namespace drive_backend 478 } // namespace drive_backend
475 } // namespace sync_file_system 479 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698