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

Unified Diff: ui/file_manager/zip_archiver/unpacker/cpp/compressor_io_javascript_stream.cc

Issue 2804453002: Move files from zip_archiver/unpacker/ to zip_archiver/. (Closed)
Patch Set: Move files from zip_archiver/unpacker/ to zip_archiver/. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/zip_archiver/unpacker/cpp/compressor_io_javascript_stream.cc
diff --git a/ui/file_manager/zip_archiver/unpacker/cpp/compressor_io_javascript_stream.cc b/ui/file_manager/zip_archiver/unpacker/cpp/compressor_io_javascript_stream.cc
deleted file mode 100644
index 5fdb081f15e4df94925111e85d987a8302f11d7c..0000000000000000000000000000000000000000
--- a/ui/file_manager/zip_archiver/unpacker/cpp/compressor_io_javascript_stream.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2017 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "compressor_io_javascript_stream.h"
-
-#include <limits>
-#include <thread>
-
-#include "archive.h"
-#include "ppapi/cpp/logging.h"
-
-CompressorIOJavaScriptStream::CompressorIOJavaScriptStream(
- JavaScriptCompressorRequestorInterface* requestor)
- : requestor_(requestor) {
- pthread_mutex_init(&shared_state_lock_, NULL);
- pthread_cond_init(&available_data_cond_, NULL);
- pthread_cond_init(&data_written_cond_, NULL);
-
- pthread_mutex_lock(&shared_state_lock_);
- available_data_ = false;
- pthread_mutex_unlock(&shared_state_lock_);
-}
-
-CompressorIOJavaScriptStream::~CompressorIOJavaScriptStream() {
- pthread_cond_destroy(&data_written_cond_);
- pthread_cond_destroy(&available_data_cond_);
- pthread_mutex_destroy(&shared_state_lock_);
-};
-
-int64_t CompressorIOJavaScriptStream::Write(int64_t byte_to_write,
- const pp::VarArrayBuffer& buffer) {
- pthread_mutex_lock(&shared_state_lock_);
- requestor_->WriteChunkRequest(byte_to_write, buffer);
-
- pthread_cond_wait(&data_written_cond_, &shared_state_lock_);
-
- int64_t written_bytes = written_bytes_;
- pthread_mutex_unlock(&shared_state_lock_);
-
- return written_bytes;
-}
-
-void CompressorIOJavaScriptStream::WriteChunkDone(int64_t written_bytes) {
- pthread_mutex_lock(&shared_state_lock_);
- written_bytes_ = written_bytes;
- pthread_cond_signal(&data_written_cond_);
- pthread_mutex_unlock(&shared_state_lock_);
-}
-
-int64_t CompressorIOJavaScriptStream::Read(int64_t bytes_to_read,
- char* destination_buffer) {
- pthread_mutex_lock(&shared_state_lock_);
-
- destination_buffer_ = destination_buffer;
- requestor_->ReadFileChunkRequest(bytes_to_read);
-
- while (!available_data_) {
- pthread_cond_wait(&available_data_cond_, &shared_state_lock_);
- }
-
- int64_t read_bytes = read_bytes_;
- available_data_ = false;
- pthread_mutex_unlock(&shared_state_lock_);
- return read_bytes;
-}
-
-void CompressorIOJavaScriptStream::ReadFileChunkDone(int64_t read_bytes,
- pp::VarArrayBuffer* array_buffer) {
- pthread_mutex_lock(&shared_state_lock_);
-
- // JavaScript sets a negative value in read_bytes if an error occurred while
- // reading a chunk.
- if (read_bytes >= 0) {
- char* array_buffer_data = static_cast<char*>(array_buffer->Map());
- memcpy(destination_buffer_, array_buffer_data, read_bytes);
- array_buffer->Unmap();
- }
-
- read_bytes_ = read_bytes;
- available_data_ = true;
- pthread_cond_signal(&available_data_cond_);
- pthread_mutex_unlock(&shared_state_lock_);
-}

Powered by Google App Engine
This is Rietveld 408576698