| OLD | NEW |
| 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/local_discovery/storage/privet_filesystem_operations.h" | 5 #include "chrome/browser/local_discovery/storage/privet_filesystem_operations.h" |
| 6 | 6 |
| 7 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" | 7 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" |
| 8 | 8 |
| 9 namespace local_discovery { | 9 namespace local_discovery { |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 void PrivetFileSystemAsyncOperationUtil::OnGotDeviceDescription( | 81 void PrivetFileSystemAsyncOperationUtil::OnGotDeviceDescription( |
| 82 bool success, const DeviceDescription& device_description) { | 82 bool success, const DeviceDescription& device_description) { |
| 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 84 if (!success) { | 84 if (!success) { |
| 85 delegate_->PrivetFileSystemResolved(NULL, parsed_path_.path); | 85 delegate_->PrivetFileSystemResolved(NULL, parsed_path_.path); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 | 88 |
| 89 privet_async_factory_ = PrivetHTTPAsynchronousFactory::CreateInstance( | 89 privet_async_factory_ = PrivetHTTPAsynchronousFactory::CreateInstance( |
| 90 service_discovery_client_.get(), | 90 service_discovery_client_.get(), request_context_.get()); |
| 91 request_context_.get()); | |
| 92 privet_http_resolution_ = privet_async_factory_->CreatePrivetHTTP( | 91 privet_http_resolution_ = privet_async_factory_->CreatePrivetHTTP( |
| 93 parsed_path_.service_name, | 92 parsed_path_.service_name, |
| 94 device_description.address, | 93 device_description.address, |
| 95 base::Bind(&PrivetFileSystemAsyncOperationUtil::OnGotPrivetHTTP, | 94 base::Bind(&PrivetFileSystemAsyncOperationUtil::OnGotPrivetHTTP, |
| 96 base::Unretained(this))); | 95 base::Unretained(this))); |
| 97 privet_http_resolution_->Start(); | 96 privet_http_resolution_->Start(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void PrivetFileSystemAsyncOperationUtil::OnGotPrivetHTTP( | 99 void PrivetFileSystemAsyncOperationUtil::OnGotPrivetHTTP( |
| 101 scoped_ptr<PrivetHTTPClient> privet_http_client) { | 100 scoped_ptr<PrivetHTTPClient> privet_http_client) { |
| 102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 101 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 103 privet_client_ = privet_http_client.Pass(); | 102 privet_client_ = PrivetV1HTTPClient::CreateDefault(privet_http_client.Pass()); |
| 104 delegate_->PrivetFileSystemResolved(privet_client_.get(), | 103 delegate_->PrivetFileSystemResolved(privet_client_.get(), |
| 105 parsed_path_.path); | 104 parsed_path_.path); |
| 106 } | 105 } |
| 107 | 106 |
| 108 PrivetFileSystemListOperation::PrivetFileSystemListOperation( | 107 PrivetFileSystemListOperation::PrivetFileSystemListOperation( |
| 109 const base::FilePath& full_path, | 108 const base::FilePath& full_path, |
| 110 content::BrowserContext* browser_context, | 109 content::BrowserContext* browser_context, |
| 111 PrivetFileSystemAsyncOperationContainer* container, | 110 PrivetFileSystemAsyncOperationContainer* container, |
| 112 PrivetFileSystemAttributeCache* attribute_cache, | 111 PrivetFileSystemAttributeCache* attribute_cache, |
| 113 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) | 112 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) |
| 114 : core_(full_path, browser_context, this), | 113 : core_(full_path, browser_context, this), |
| 115 full_path_(full_path), | 114 full_path_(full_path), |
| 116 container_(container), | 115 container_(container), |
| 117 attribute_cache_(attribute_cache), | 116 attribute_cache_(attribute_cache), |
| 118 callback_(callback) { | 117 callback_(callback) { |
| 119 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 118 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 120 } | 119 } |
| 121 | 120 |
| 122 PrivetFileSystemListOperation::~PrivetFileSystemListOperation() { | 121 PrivetFileSystemListOperation::~PrivetFileSystemListOperation() { |
| 123 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void PrivetFileSystemListOperation::Start() { | 125 void PrivetFileSystemListOperation::Start() { |
| 127 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 128 core_.Start(); | 127 core_.Start(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void PrivetFileSystemListOperation::PrivetFileSystemResolved( | 130 void PrivetFileSystemListOperation::PrivetFileSystemResolved( |
| 132 PrivetHTTPClient* http_client, | 131 PrivetV1HTTPClient* http_client, |
| 133 const std::string& path) { | 132 const std::string& path) { |
| 134 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 133 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 135 if (!http_client) { | 134 if (!http_client) { |
| 136 SignalError(); | 135 SignalError(); |
| 137 return; | 136 return; |
| 138 } | 137 } |
| 139 | 138 |
| 140 list_operation_ = http_client->CreateStorageListOperation( | 139 list_operation_ = http_client->CreateStorageListOperation( |
| 141 path, | 140 path, |
| 142 base::Bind(&PrivetFileSystemListOperation::OnStorageListResult, | 141 base::Bind(&PrivetFileSystemListOperation::OnStorageListResult, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const base::File::Info* info = attribute_cache_->GetFileInfo(full_path_); | 233 const base::File::Info* info = attribute_cache_->GetFileInfo(full_path_); |
| 235 if (info) { | 234 if (info) { |
| 236 TriggerCallbackAndDestroy(base::File::FILE_OK, *info); | 235 TriggerCallbackAndDestroy(base::File::FILE_OK, *info); |
| 237 return; | 236 return; |
| 238 } | 237 } |
| 239 | 238 |
| 240 core_.Start(); | 239 core_.Start(); |
| 241 } | 240 } |
| 242 | 241 |
| 243 void PrivetFileSystemDetailsOperation::PrivetFileSystemResolved( | 242 void PrivetFileSystemDetailsOperation::PrivetFileSystemResolved( |
| 244 PrivetHTTPClient* http_client, | 243 PrivetV1HTTPClient* http_client, |
| 245 const std::string& path) { | 244 const std::string& path) { |
| 246 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 245 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 247 if (!http_client) { | 246 if (!http_client) { |
| 248 SignalError(); | 247 SignalError(); |
| 249 return; | 248 return; |
| 250 } | 249 } |
| 251 | 250 |
| 252 list_operation_ = http_client->CreateStorageListOperation( | 251 list_operation_ = http_client->CreateStorageListOperation( |
| 253 path, | 252 path, |
| 254 base::Bind(&PrivetFileSystemDetailsOperation::OnStorageListResult, | 253 base::Bind(&PrivetFileSystemDetailsOperation::OnStorageListResult, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 280 base::File::Error result, | 279 base::File::Error result, |
| 281 const base::File::Info& info) { | 280 const base::File::Info& info) { |
| 282 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 281 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 283 content::BrowserThread::PostTask(content::BrowserThread::IO, | 282 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 284 FROM_HERE, | 283 FROM_HERE, |
| 285 base::Bind(callback_, result, info)); | 284 base::Bind(callback_, result, info)); |
| 286 container_->RemoveOperation(this); | 285 container_->RemoveOperation(this); |
| 287 } | 286 } |
| 288 | 287 |
| 289 } // namespace local_discovery | 288 } // namespace local_discovery |
| OLD | NEW |