OLD | NEW |
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 "components/nacl/browser/pnacl_host.h" | 5 #include "components/nacl/browser/pnacl_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 pt->callback.Run(base::File(), false); | 388 pt->callback.Run(base::File(), false); |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 //////////////////// GetNexeFd miss path | 392 //////////////////// GetNexeFd miss path |
393 // Return the temp fd to the renderer, reporting a miss. | 393 // Return the temp fd to the renderer, reporting a miss. |
394 void PnaclHost::ReturnMiss(const PendingTranslationMap::iterator& entry) { | 394 void PnaclHost::ReturnMiss(const PendingTranslationMap::iterator& entry) { |
395 // Return the fd | 395 // Return the fd |
396 PendingTranslation* pt = &entry->second; | 396 PendingTranslation* pt = &entry->second; |
397 NexeFdCallback cb(pt->callback); | 397 NexeFdCallback cb(pt->callback); |
398 cb.Run(*pt->nexe_fd, false); | 398 cb.Run(pt->nexe_fd->Duplicate(), false); |
399 if (!pt->nexe_fd->IsValid()) { | 399 if (!pt->nexe_fd->IsValid()) { |
400 // Bad FD is unrecoverable, so clear out the entry. | 400 // Bad FD is unrecoverable, so clear out the entry. |
401 pending_translations_.erase(entry); | 401 pending_translations_.erase(entry); |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 // On error, just return a null refptr. | 405 // On error, just return a null refptr. |
406 // static | 406 // static |
407 scoped_refptr<net::DrainableIOBuffer> PnaclHost::CopyFileToBuffer( | 407 scoped_refptr<net::DrainableIOBuffer> PnaclHost::CopyFileToBuffer( |
408 std::unique_ptr<base::File> file) { | 408 std::unique_ptr<base::File> file) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 } | 557 } |
558 if (file_error == -1) { | 558 if (file_error == -1) { |
559 // Write error on the temp file. Request a new file and start over. | 559 // Write error on the temp file. Request a new file and start over. |
560 BrowserThread::PostBlockingPoolTask( | 560 BrowserThread::PostBlockingPoolTask( |
561 FROM_HERE, | 561 FROM_HERE, |
562 base::Bind(CloseScopedFile, Passed(&file))); | 562 base::Bind(CloseScopedFile, Passed(&file))); |
563 CreateTemporaryFile(base::Bind(&PnaclHost::OnTempFileReturn, | 563 CreateTemporaryFile(base::Bind(&PnaclHost::OnTempFileReturn, |
564 base::Unretained(this), entry->first)); | 564 base::Unretained(this), entry->first)); |
565 return; | 565 return; |
566 } | 566 } |
567 entry->second.callback.Run(*file.get(), true); | 567 entry->second.callback.Run(file->Duplicate(), true); |
568 BrowserThread::PostBlockingPoolTask( | 568 BrowserThread::PostBlockingPoolTask( |
569 FROM_HERE, | 569 FROM_HERE, |
570 base::Bind(CloseScopedFile, Passed(&file))); | 570 base::Bind(CloseScopedFile, Passed(&file))); |
571 pending_translations_.erase(entry); | 571 pending_translations_.erase(entry); |
572 } | 572 } |
573 | 573 |
574 /////////////////// | 574 /////////////////// |
575 | 575 |
576 void PnaclHost::RendererClosing(int render_process_id) { | 576 void PnaclHost::RendererClosing(int render_process_id) { |
577 DCHECK(thread_checker_.CalledOnValidThread()); | 577 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 DCHECK(pending_backend_operations_ >= 0); | 659 DCHECK(pending_backend_operations_ >= 0); |
660 if (pending_translations_.empty() && | 660 if (pending_translations_.empty() && |
661 pending_backend_operations_ <= 0 && | 661 pending_backend_operations_ <= 0 && |
662 cache_state_ == CacheReady) { | 662 cache_state_ == CacheReady) { |
663 cache_state_ = CacheUninitialized; | 663 cache_state_ = CacheUninitialized; |
664 disk_cache_.reset(); | 664 disk_cache_.reset(); |
665 } | 665 } |
666 } | 666 } |
667 | 667 |
668 } // namespace pnacl | 668 } // namespace pnacl |
OLD | NEW |