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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_service.cc

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/local/local_file_sync_service.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (next_ == change_count_map_.end()) 63 if (next_ == change_count_map_.end())
64 next_ = change_count_map_.begin(); 64 next_ = change_count_map_.begin();
65 DCHECK_NE(0, next_->second); 65 DCHECK_NE(0, next_->second);
66 *origin = next_++->first; 66 *origin = next_++->first;
67 if (!ContainsKey(disabled_origins_, *origin)) 67 if (!ContainsKey(disabled_origins_, *origin))
68 return true; 68 return true;
69 } while (next_ != begin); 69 } while (next_ != begin);
70 return false; 70 return false;
71 } 71 }
72 72
73 int64 LocalFileSyncService::OriginChangeMap::GetTotalChangeCount() const { 73 int64_t LocalFileSyncService::OriginChangeMap::GetTotalChangeCount() const {
74 int64 num_changes = 0; 74 int64_t num_changes = 0;
75 for (Map::const_iterator iter = change_count_map_.begin(); 75 for (Map::const_iterator iter = change_count_map_.begin();
76 iter != change_count_map_.end(); ++iter) { 76 iter != change_count_map_.end(); ++iter) {
77 if (ContainsKey(disabled_origins_, iter->first)) 77 if (ContainsKey(disabled_origins_, iter->first))
78 continue; 78 continue;
79 num_changes += iter->second; 79 num_changes += iter->second;
80 } 80 }
81 return num_changes; 81 return num_changes;
82 } 82 }
83 83
84 void LocalFileSyncService::OriginChangeMap::SetOriginChangeCount( 84 void LocalFileSyncService::OriginChangeMap::SetOriginChangeCount(
85 const GURL& origin, int64 changes) { 85 const GURL& origin,
86 int64_t changes) {
86 if (changes != 0) { 87 if (changes != 0) {
87 change_count_map_[origin] = changes; 88 change_count_map_[origin] = changes;
88 return; 89 return;
89 } 90 }
90 Map::iterator found = change_count_map_.find(origin); 91 Map::iterator found = change_count_map_.find(origin);
91 if (found != change_count_map_.end()) { 92 if (found != change_count_map_.end()) {
92 if (next_ == found) 93 if (next_ == found)
93 ++next_; 94 ++next_;
94 change_count_map_.erase(found); 95 change_count_map_.erase(found);
95 } 96 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 need_notification = true; 323 need_notification = true;
323 SyncFileSystemBackend* backend = 324 SyncFileSystemBackend* backend =
324 SyncFileSystemBackend::GetBackend(origin_to_contexts_[origin]); 325 SyncFileSystemBackend::GetBackend(origin_to_contexts_[origin]);
325 DCHECK(backend); 326 DCHECK(backend);
326 DCHECK(backend->change_tracker()); 327 DCHECK(backend->change_tracker());
327 origin_change_map_.SetOriginChangeCount( 328 origin_change_map_.SetOriginChangeCount(
328 origin, backend->change_tracker()->num_changes()); 329 origin, backend->change_tracker()->num_changes());
329 } 330 }
330 if (!need_notification) 331 if (!need_notification)
331 return; 332 return;
332 int64 num_changes = origin_change_map_.GetTotalChangeCount(); 333 int64_t num_changes = origin_change_map_.GetTotalChangeCount();
333 FOR_EACH_OBSERVER(Observer, change_observers_, 334 FOR_EACH_OBSERVER(Observer, change_observers_,
334 OnLocalChangeAvailable(num_changes)); 335 OnLocalChangeAvailable(num_changes));
335 } 336 }
336 337
337 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) { 338 void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) {
338 if (!ContainsKey(origin_to_contexts_, origin)) 339 if (!ContainsKey(origin_to_contexts_, origin))
339 return; 340 return;
340 origin_change_map_.SetOriginEnabled(origin, enabled); 341 origin_change_map_.SetOriginEnabled(origin, enabled);
341 } 342 }
342 343
(...skipping 26 matching lines...) Expand all
369 if (pending_origins_with_changes_.find(app_origin) != 370 if (pending_origins_with_changes_.find(app_origin) !=
370 pending_origins_with_changes_.end()) { 371 pending_origins_with_changes_.end()) {
371 // We have remaining changes for the origin. 372 // We have remaining changes for the origin.
372 pending_origins_with_changes_.erase(app_origin); 373 pending_origins_with_changes_.erase(app_origin);
373 SyncFileSystemBackend* backend = 374 SyncFileSystemBackend* backend =
374 SyncFileSystemBackend::GetBackend(file_system_context); 375 SyncFileSystemBackend::GetBackend(file_system_context);
375 DCHECK(backend); 376 DCHECK(backend);
376 DCHECK(backend->change_tracker()); 377 DCHECK(backend->change_tracker());
377 origin_change_map_.SetOriginChangeCount( 378 origin_change_map_.SetOriginChangeCount(
378 app_origin, backend->change_tracker()->num_changes()); 379 app_origin, backend->change_tracker()->num_changes());
379 int64 num_changes = origin_change_map_.GetTotalChangeCount(); 380 int64_t num_changes = origin_change_map_.GetTotalChangeCount();
380 FOR_EACH_OBSERVER(Observer, change_observers_, 381 FOR_EACH_OBSERVER(Observer, change_observers_,
381 OnLocalChangeAvailable(num_changes)); 382 OnLocalChangeAvailable(num_changes));
382 } 383 }
383 callback.Run(status); 384 callback.Run(status);
384 } 385 }
385 386
386 void LocalFileSyncService::DidInitializeForRemoteSync( 387 void LocalFileSyncService::DidInitializeForRemoteSync(
387 const FileSystemURL& url, 388 const FileSystemURL& url,
388 storage::FileSystemContext* file_system_context, 389 storage::FileSystemContext* file_system_context,
389 const PrepareChangeCallback& callback, 390 const PrepareChangeCallback& callback,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 492
492 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor( 493 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor(
493 const FileSystemURL& url) { 494 const FileSystemURL& url) {
494 if (!get_local_change_processor_.is_null()) 495 if (!get_local_change_processor_.is_null())
495 return get_local_change_processor_.Run(url.origin()); 496 return get_local_change_processor_.Run(url.origin());
496 DCHECK(local_change_processor_); 497 DCHECK(local_change_processor_);
497 return local_change_processor_; 498 return local_change_processor_;
498 } 499 }
499 500
500 } // namespace sync_file_system 501 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698