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

Side by Side Diff: chrome/browser/extensions/api/sync_file_system/sync_file_system_api.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 (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/extensions/api/sync_file_system/sync_file_system_api.h" 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Bind(&fileapi::FileSystemContext::DeleteFileSystem, 83 Bind(&fileapi::FileSystemContext::DeleteFileSystem,
84 file_system_context, 84 file_system_context,
85 source_url().GetOrigin(), 85 source_url().GetOrigin(),
86 file_system_url.type(), 86 file_system_url.type(),
87 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem, 87 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem,
88 this))); 88 this)));
89 return true; 89 return true;
90 } 90 }
91 91
92 void SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem( 92 void SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem(
93 base::PlatformFileError error) { 93 base::File::Error error) {
94 // Repost to switch from IO thread to UI thread for SendResponse(). 94 // Repost to switch from IO thread to UI thread for SendResponse().
95 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 95 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
97 BrowserThread::PostTask( 97 BrowserThread::PostTask(
98 BrowserThread::UI, 98 BrowserThread::UI,
99 FROM_HERE, 99 FROM_HERE,
100 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem, this, 100 Bind(&SyncFileSystemDeleteFileSystemFunction::DidDeleteFileSystem, this,
101 error)); 101 error));
102 return; 102 return;
103 } 103 }
104 104
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
106 if (error != base::PLATFORM_FILE_OK) { 106 if (error != base::File::FILE_OK) {
107 error_ = ErrorToString( 107 error_ = ErrorToString(sync_file_system::FileErrorToSyncStatusCode(error));
108 sync_file_system::PlatformFileErrorToSyncStatusCode(error));
109 SetResult(new base::FundamentalValue(false)); 108 SetResult(new base::FundamentalValue(false));
110 SendResponse(false); 109 SendResponse(false);
111 return; 110 return;
112 } 111 }
113 112
114 SetResult(new base::FundamentalValue(true)); 113 SetResult(new base::FundamentalValue(true));
115 SendResponse(true); 114 SendResponse(true);
116 } 115 }
117 116
118 bool SyncFileSystemRequestFileSystemFunction::RunImpl() { 117 bool SyncFileSystemRequestFileSystemFunction::RunImpl() {
(...skipping 19 matching lines...) Expand all
138 SyncFileSystemRequestFileSystemFunction::GetFileSystemContext() { 137 SyncFileSystemRequestFileSystemFunction::GetFileSystemContext() {
139 DCHECK(render_view_host()); 138 DCHECK(render_view_host());
140 return BrowserContext::GetStoragePartition( 139 return BrowserContext::GetStoragePartition(
141 GetProfile(), render_view_host()->GetSiteInstance()) 140 GetProfile(), render_view_host()->GetSiteInstance())
142 ->GetFileSystemContext(); 141 ->GetFileSystemContext();
143 } 142 }
144 143
145 void SyncFileSystemRequestFileSystemFunction::DidOpenFileSystem( 144 void SyncFileSystemRequestFileSystemFunction::DidOpenFileSystem(
146 const GURL& root_url, 145 const GURL& root_url,
147 const std::string& file_system_name, 146 const std::string& file_system_name,
148 base::PlatformFileError error) { 147 base::File::Error error) {
149 // Repost to switch from IO thread to UI thread for SendResponse(). 148 // Repost to switch from IO thread to UI thread for SendResponse().
150 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 149 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
152 BrowserThread::PostTask( 151 BrowserThread::PostTask(
153 BrowserThread::UI, FROM_HERE, 152 BrowserThread::UI, FROM_HERE,
154 Bind(&SyncFileSystemRequestFileSystemFunction::DidOpenFileSystem, 153 Bind(&SyncFileSystemRequestFileSystemFunction::DidOpenFileSystem,
155 this, root_url, file_system_name, error)); 154 this, root_url, file_system_name, error));
156 return; 155 return;
157 } 156 }
158 157
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
160 if (error != base::PLATFORM_FILE_OK) { 159 if (error != base::File::FILE_OK) {
161 error_ = ErrorToString( 160 error_ = ErrorToString(sync_file_system::FileErrorToSyncStatusCode(error));
162 sync_file_system::PlatformFileErrorToSyncStatusCode(error));
163 SendResponse(false); 161 SendResponse(false);
164 return; 162 return;
165 } 163 }
166 164
167 base::DictionaryValue* dict = new base::DictionaryValue(); 165 base::DictionaryValue* dict = new base::DictionaryValue();
168 SetResult(dict); 166 SetResult(dict);
169 dict->SetString("name", file_system_name); 167 dict->SetString("name", file_system_name);
170 dict->SetString("root", root_url.spec()); 168 dict->SetString("root", root_url.spec());
171 SendResponse(true); 169 SendResponse(true);
172 } 170 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 376
379 bool SyncFileSystemGetServiceStatusFunction::RunImpl() { 377 bool SyncFileSystemGetServiceStatusFunction::RunImpl() {
380 sync_file_system::SyncFileSystemService* service = 378 sync_file_system::SyncFileSystemService* service =
381 GetSyncFileSystemService(GetProfile()); 379 GetSyncFileSystemService(GetProfile());
382 results_ = api::sync_file_system::GetServiceStatus::Results::Create( 380 results_ = api::sync_file_system::GetServiceStatus::Results::Create(
383 SyncServiceStateToExtensionEnum(service->GetSyncServiceState())); 381 SyncServiceStateToExtensionEnum(service->GetSyncServiceState()));
384 return true; 382 return true;
385 } 383 }
386 384
387 } // namespace extensions 385 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698