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

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

Issue 2425553002: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/sync_file_system (Closed)
Patch Set: Created 4 years, 2 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_status.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "storage/common/fileapi/file_system_util.h" 10 #include "storage/common/fileapi/file_system_util.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void LocalFileSyncStatus::EndWriting(const FileSystemURL& url) { 87 void LocalFileSyncStatus::EndWriting(const FileSystemURL& url) {
88 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 88 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
89 base::FilePath normalized_path = NormalizePath(url.path()); 89 base::FilePath normalized_path = NormalizePath(url.path());
90 OriginAndType origin_and_type = GetOriginAndType(url); 90 OriginAndType origin_and_type = GetOriginAndType(url);
91 91
92 int count = --writing_[origin_and_type][normalized_path]; 92 int count = --writing_[origin_and_type][normalized_path];
93 if (count == 0) { 93 if (count == 0) {
94 writing_[origin_and_type].erase(normalized_path); 94 writing_[origin_and_type].erase(normalized_path);
95 if (writing_[origin_and_type].empty()) 95 if (writing_[origin_and_type].empty())
96 writing_.erase(origin_and_type); 96 writing_.erase(origin_and_type);
97 FOR_EACH_OBSERVER(Observer, observer_list_, OnSyncEnabled(url)); 97 for (auto& observer : observer_list_)
98 observer.OnSyncEnabled(url);
98 } 99 }
99 } 100 }
100 101
101 void LocalFileSyncStatus::StartSyncing(const FileSystemURL& url) { 102 void LocalFileSyncStatus::StartSyncing(const FileSystemURL& url) {
102 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
103 DCHECK(!IsChildOrParentWriting(url)); 104 DCHECK(!IsChildOrParentWriting(url));
104 DCHECK(!IsChildOrParentSyncing(url)); 105 DCHECK(!IsChildOrParentSyncing(url));
105 syncing_[GetOriginAndType(url)].insert(NormalizePath(url.path())); 106 syncing_[GetOriginAndType(url)].insert(NormalizePath(url.path()));
106 } 107 }
107 108
108 void LocalFileSyncStatus::EndSyncing(const FileSystemURL& url) { 109 void LocalFileSyncStatus::EndSyncing(const FileSystemURL& url) {
109 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 110 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
110 base::FilePath normalized_path = NormalizePath(url.path()); 111 base::FilePath normalized_path = NormalizePath(url.path());
111 OriginAndType origin_and_type = GetOriginAndType(url); 112 OriginAndType origin_and_type = GetOriginAndType(url);
112 113
113 syncing_[origin_and_type].erase(normalized_path); 114 syncing_[origin_and_type].erase(normalized_path);
114 if (syncing_[origin_and_type].empty()) 115 if (syncing_[origin_and_type].empty())
115 syncing_.erase(origin_and_type); 116 syncing_.erase(origin_and_type);
116 FOR_EACH_OBSERVER(Observer, observer_list_, OnSyncEnabled(url)); 117 for (auto& observer : observer_list_)
117 FOR_EACH_OBSERVER(Observer, observer_list_, OnWriteEnabled(url)); 118 observer.OnSyncEnabled(url);
119 for (auto& observer : observer_list_)
120 observer.OnWriteEnabled(url);
118 } 121 }
119 122
120 bool LocalFileSyncStatus::IsWriting(const FileSystemURL& url) const { 123 bool LocalFileSyncStatus::IsWriting(const FileSystemURL& url) const {
121 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 124 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
122 return IsChildOrParentWriting(url); 125 return IsChildOrParentWriting(url);
123 } 126 }
124 127
125 bool LocalFileSyncStatus::IsWritable(const FileSystemURL& url) const { 128 bool LocalFileSyncStatus::IsWritable(const FileSystemURL& url) const {
126 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 129 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
127 return !IsChildOrParentSyncing(url); 130 return !IsChildOrParentSyncing(url);
(...skipping 29 matching lines...) Expand all
157 const FileSystemURL& url) const { 160 const FileSystemURL& url) const {
158 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 161 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
159 URLSet::const_iterator found = syncing_.find(GetOriginAndType(url)); 162 URLSet::const_iterator found = syncing_.find(GetOriginAndType(url));
160 if (found == syncing_.end()) 163 if (found == syncing_.end())
161 return false; 164 return false;
162 return ContainsChildOrParent(found->second, url.path(), 165 return ContainsChildOrParent(found->second, url.path(),
163 SetKeyHelper()); 166 SetKeyHelper());
164 } 167 }
165 168
166 } // namespace sync_file_system 169 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698