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/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 GDataFileSystem::~GDataFileSystem() { | 926 GDataFileSystem::~GDataFileSystem() { |
927 // This should be called from UI thread, from GDataSystemService shutdown. | 927 // This should be called from UI thread, from GDataSystemService shutdown. |
928 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 928 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
929 | 929 |
930 pref_registrar_.reset(NULL); | 930 pref_registrar_.reset(NULL); |
931 | 931 |
932 // ui_weak_ptr_factory_ must be deleted on UI thread. | 932 // ui_weak_ptr_factory_ must be deleted on UI thread. |
933 ui_weak_ptr_factory_.reset(); | 933 ui_weak_ptr_factory_.reset(); |
934 | 934 |
935 // We should wait if there is any pending tasks posted to the worker | 935 { |
936 // thread pool. on_io_completed_ won't be signaled iff |num_pending_tasks_| | 936 // http://crbug.com/125220 |
937 // is greater that 0. | 937 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
938 // We don't have to lock with |num_pending_tasks_lock_| here, since number of | 938 // We should wait if there is any pending tasks posted to the worker |
939 // pending tasks can only decrease at this point (Number of pending class can | 939 // thread pool. on_io_completed_ won't be signaled iff |num_pending_tasks_| |
940 // be increased only on UI and IO thread. We are on UI thread, and there will | 940 // is greater that 0. |
941 // be no more tasks run on IO thread. | 941 // We don't have to lock with |num_pending_tasks_lock_| here, since number |
942 on_io_completed_->Wait(); | 942 // of pending tasks can only decrease at this point (Number of pending class |
| 943 // can be increased only on UI and IO thread. We are on UI thread, and there |
| 944 // will be no more tasks run on IO thread. |
| 945 on_io_completed_->Wait(); |
| 946 } |
943 | 947 |
944 // Now that we are sure that there are no more pending tasks bound to this on | 948 // Now that we are sure that there are no more pending tasks bound to this on |
945 // other threads, we are safe to destroy the data members. | 949 // other threads, we are safe to destroy the data members. |
946 | 950 |
947 // Cancel all the in-flight operations. | 951 // Cancel all the in-flight operations. |
948 // This asynchronously cancels the URL fetch operations. | 952 // This asynchronously cancels the URL fetch operations. |
949 documents_service_->CancelAll(); | 953 documents_service_->CancelAll(); |
950 documents_service_.reset(); | 954 documents_service_.reset(); |
951 | 955 |
952 // Lock to let root destroy cache map and resource map. | 956 // Lock to let root destroy cache map and resource map. |
(...skipping 3630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4583 pref_registrar_->Init(profile_->GetPrefs()); | 4587 pref_registrar_->Init(profile_->GetPrefs()); |
4584 pref_registrar_->Add(prefs::kDisableGDataHostedFiles, this); | 4588 pref_registrar_->Add(prefs::kDisableGDataHostedFiles, this); |
4585 } | 4589 } |
4586 | 4590 |
4587 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { | 4591 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { |
4588 delete global_free_disk_getter_for_testing; // Safe to delete NULL; | 4592 delete global_free_disk_getter_for_testing; // Safe to delete NULL; |
4589 global_free_disk_getter_for_testing = getter; | 4593 global_free_disk_getter_for_testing = getter; |
4590 } | 4594 } |
4591 | 4595 |
4592 } // namespace gdata | 4596 } // namespace gdata |
OLD | NEW |