summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 22:39:51 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 22:39:51 +0000
commit7ce082c0725230c4e514e5cb3b78c9e80a65fa9c (patch)
tree2abd5b7c0f5ecf6501fefb82ba1ad0078906c8ec
parent3976928a9336d1871501ff9454b5b9160be03ecb (diff)
downloadchromium_src-7ce082c0725230c4e514e5cb3b78c9e80a65fa9c.zip
chromium_src-7ce082c0725230c4e514e5cb3b78c9e80a65fa9c.tar.gz
chromium_src-7ce082c0725230c4e514e5cb3b78c9e80a65fa9c.tar.bz2
Revert 147725 - Helper extension+plugin for testing NaCl part of File API.
TEST=none BUG=none Review URL: https://chromiumcodereview.appspot.com/10692031 TBR=zelidrag@chromium.org Review URL: https://chromiumcodereview.appspot.com/10810046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147729 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi5
-rw-r--r--chrome/test/chromeos/utilities/file_helper/extension/event.js21
-rw-r--r--chrome/test/chromeos/utilities/file_helper/extension/file_helper_newlib.nmf6
-rw-r--r--chrome/test/chromeos/utilities/file_helper/extension/manifest.json30
-rw-r--r--chrome/test/chromeos/utilities/file_helper/extension/test.html23
-rw-r--r--chrome/test/chromeos/utilities/file_helper/extension/test.js74
-rw-r--r--chrome/test/chromeos/utilities/file_helper/file_helper.gyp58
-rw-r--r--chrome/test/chromeos/utilities/file_helper/plugin/file_helper.cc336
8 files changed, 0 insertions, 553 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 11da6e2..7157d1d 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -3162,11 +3162,6 @@
'../build/linux/system.gyp:dbus',
],
}],
- ['disable_nacl==0 and chromeos==1', {
- 'dependencies': [
- '../chrome/test/chromeos/utilities/file_helper/file_helper.gyp:file_helper_nexe',
- ],
- }],
['file_manager_extension==0', {
'sources!': [
'browser/ui/views/select_file_dialog_extension_browsertest.cc',
diff --git a/chrome/test/chromeos/utilities/file_helper/extension/event.js b/chrome/test/chromeos/utilities/file_helper/extension/event.js
deleted file mode 100644
index 8b5095a..0000000
--- a/chrome/test/chromeos/utilities/file_helper/extension/event.js
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-if(chrome.fileBrowserHandler) {
- chrome.fileBrowserHandler.onExecute.addListener(
- function(id, details) {
- if (id == 'view')
- OnExecute(details.entries);
- });
-}
-
-function OnExecute(entries) {
- if (!entries || !entries[0])
- return;
-
- chrome.tabs.create({
- url: "test.html?file=" + escape(entries[0].fullPath)
- });
-}
-
diff --git a/chrome/test/chromeos/utilities/file_helper/extension/file_helper_newlib.nmf b/chrome/test/chromeos/utilities/file_helper/extension/file_helper_newlib.nmf
deleted file mode 100644
index 9f6730e..0000000
--- a/chrome/test/chromeos/utilities/file_helper/extension/file_helper_newlib.nmf
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "program": {
- "x86-64": {"url": "file_helper_newlib_x64.nexe"},
- "x86-32": {"url": "file_helper_newlib_x32.nexe"}
- }
-}
diff --git a/chrome/test/chromeos/utilities/file_helper/extension/manifest.json b/chrome/test/chromeos/utilities/file_helper/extension/manifest.json
deleted file mode 100644
index 4668996..0000000
--- a/chrome/test/chromeos/utilities/file_helper/extension/manifest.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDOuXEIuoK1kAkBe0SKiJn/N9oNn3oUxGa4dwj40MnJqPn+w0aR2vuyocm0R4Drp67aYwtLjOVPF4CICRq6ICP6eU07gGwQxGdZ7HJASXV8hm0tab5I70oJmRLfFJyVAMCeWlFaOGq05v2i6EbifZM0qO5xALKNGQt+yjXi5INM5wIBIw==",
- "name": "nacl fileio tests",
- "version": "0.1",
- "manifest_version": 2,
- "incognito" : "split",
- "description": "Tests that embeded nacl plugin has same permissions to file system as the extension.",
- "app": {
- "launch": {
- "local_path": "test.html"
- }
- },
- "background": {
- "scripts": ["event.js"],
- "persistent": false
- },
- "file_browser_handlers": [
- {
- "id": "view",
- "default_title": "NaCl File Helper.",
- "file_filters": [
- "filesystem:*.txt"
- ]
- }
- ],
- "permissions": [
- "unlimitedStorage",
- "fileBrowserHandler"
- ]
-}
diff --git a/chrome/test/chromeos/utilities/file_helper/extension/test.html b/chrome/test/chromeos/utilities/file_helper/extension/test.html
deleted file mode 100644
index 3be81a4..0000000
--- a/chrome/test/chromeos/utilities/file_helper/extension/test.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<html>
-<script src="test.js"></script>
-<body>
-<p>
-This is sample fileHandler extension that uses NaCl plugin to read .txt files on ChromiumOS.
-To run the extension, please open File Manager (ctrl + M), select some .txt file and click button "Run file-io test extension".
-As a result, extension will output the selected file's content or error message (if extension fails during reading the file, error message will be the same as the error code).
-One instance of the extension will be able to open a file only once.
-</p>
-<div id="listener">
- <embed name="nacl_module"
- id="file_reader"
- width=0 height=0
- src="file_helper_newlib.nmf"
- type="application/x-nacl" />
-</div>
-<h3>File:</h3>
-<div id="filename"></div>
-<h3>Content:</h3>
-<textarea id="content" rows="15" cols="60"></textarea>
-<button id="read_btn">Read</button><button id="write_btn">Write</button><button id="truncate_btn">Truncate</button>
-</body>
-</html>
diff --git a/chrome/test/chromeos/utilities/file_helper/extension/test.js b/chrome/test/chromeos/utilities/file_helper/extension/test.js
deleted file mode 100644
index 1845c4b..0000000
--- a/chrome/test/chromeos/utilities/file_helper/extension/test.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-function $(id) {
- return document.getElementById(id);
-}
-
-function getUrlSearchParams(search) {
- var params = {};
-
- if (search) {
- // Strips leading '?'
- search = search.substring(1);
- var pairs = search.split('&');
- for (var i = 0; i < pairs.length; ++i) {
- var pair = pairs[i].split('=');
- if (pair.length == 2) {
- params[pair[0]] = decodeURIComponent(pair[1]);
- } else {
- params[pair] = true;
- }
- }
- }
-
- return params;
-}
-
-function onPageLoad() {
- $('read_btn').addEventListener('click', onRead);
- $('write_btn').addEventListener('click', onWrite);
- $('truncate_btn').addEventListener('click', onTruncate);
-
- var listener = $('listener')
- listener.addEventListener('load', moduleDidLoad, true);
- listener.addEventListener('message', handleMessage, true);
- var params = getUrlSearchParams(location.search);
- $('filename').innerText = params['file'];
- $('content').innerText = 'Loading plugin...';
-}
-
-function moduleDidLoad(load_event) {
- $('content').innerText = 'Plugin loaded!';
- var params = getUrlSearchParams(location.search);
- onRead(params['file']);
-}
-
-function handleMessage(message_event) {
- console.log('Got message:');
- console.log(message_event);
- $('content').textContent = message_event.data;
-}
-
-function onRead(filePath) {
- $('file_reader').postMessage("readFile:" + filePath);
-}
-
-function onTruncate() {
- chrome.fileBrowserHandler.selectFile({ suggestedName: ''},
- function(result) {
- $('file_reader').postMessage("truncateFile:" + result.entry.fullPath);
- });
-}
-
-function onWrite() {
- chrome.fileBrowserHandler.selectFile({ suggestedName: ''},
- function(result) {
- $('file_reader').postMessage(
- "writeFile:" + result.entry.fullPath + ":" + $('result').textContent);
- });
-}
-
-window.addEventListener('load', onPageLoad, true);
-
diff --git a/chrome/test/chromeos/utilities/file_helper/file_helper.gyp b/chrome/test/chromeos/utilities/file_helper/file_helper.gyp
deleted file mode 100644
index d2b4348..0000000
--- a/chrome/test/chromeos/utilities/file_helper/file_helper.gyp
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- ######################################################################
- 'includes': [
- '../../../../../native_client/build/common.gypi',
- ],
- ######################################################################
- 'conditions': [
- ['target_arch!="arm"', {
- 'targets': [
- {
- 'target_name': 'file_helper_nexe',
- 'type': 'none',
- 'dependencies': [
- '<(DEPTH)/native_client/tools.gyp:prep_toolchain',
- '<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:nacl_lib',
- '<(DEPTH)/native_client/src/untrusted/irt/irt.gyp:irt_core_nexe'
- ],
- 'variables': {
- 'nexe_target': 'file_helper',
- 'build_glibc': 0,
- 'build_newlib': 1,
- 'extra_args': [
- '--strip-debug',
- ],
- },
- 'sources': [
- 'plugin/file_helper.cc',
- ],
- 'link_flags': [
- '-lppapi_cpp',
- '-lppapi',
- '-lplatform',
- '-lpthread',
- '-lgio',
- ],
- 'copies': [
- {
- 'destination': '<(PRODUCT_DIR)/test_data/chrome/extensions/file_helper',
- 'files': [
- 'extension/event.js',
- 'extension/file_helper_newlib.nmf',
- 'extension/manifest.json',
- 'extension/test.html',
- 'extension/test.js',
- '<(PRODUCT_DIR)/file_helper_newlib_x32.nexe',
- '<(PRODUCT_DIR)/file_helper_newlib_x64.nexe'
- ],
- },
- ],
- },
- ],
- }],
- ],
-}
diff --git a/chrome/test/chromeos/utilities/file_helper/plugin/file_helper.cc b/chrome/test/chromeos/utilities/file_helper/plugin/file_helper.cc
deleted file mode 100644
index 3c6fd39..0000000
--- a/chrome/test/chromeos/utilities/file_helper/plugin/file_helper.cc
+++ /dev/null
@@ -1,336 +0,0 @@
-// Copyright (c) 2012 The Chromium 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 <cstdio>
-#include <string>
-#include <vector>
-
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/cpp/completion_callback.h"
-#include "ppapi/cpp/file_io.h"
-#include "ppapi/cpp/file_ref.h"
-#include "ppapi/cpp/file_system.h"
-#include "ppapi/cpp/instance.h"
-#include "ppapi/cpp/module.h"
-#include "ppapi/cpp/var.h"
-
-namespace {
- size_t Tokenize(const std::string& str,
- const std::string& delimiters,
- std::vector<std::string>* tokens) {
- tokens->clear();
-
- std::string::size_type start = str.find_first_not_of(delimiters);
- while (start != std::string::npos) {
- std::string::size_type end = str.find_first_of(delimiters, start + 1);
- if (end == std::string::npos) {
- tokens->push_back(str.substr(start));
- break;
- } else {
- tokens->push_back(str.substr(start, end - start));
- start = str.find_first_not_of(delimiters, end + 1);
- }
- }
-
- return tokens->size();
- }
-}
-
-namespace file_reader {
-// Method name for file read command, as seen by JavaScript code.
-const char kReadMethodId[] = "readFile";
-
-// Method name for file write command, as seen by JavaScript code.
-const char kWriteMethodId[] = "writeFile";
-
-// Method name for file write command, as seen by JavaScript code.
-const char kCreateMethodId[] = "createFile";
-
-// Method name for file truncate command, as seen by JavaScript code.
-const char kTruncateMethodId[] = "truncateFile";
-
-// Separator character for the reverseText method.
-const char kMessageArgumentSeparator[] = ":";
-
-class FileHelper {
- public:
- enum FileOperation {
- OPERATION_UNKNOWN,
- OPERATION_READ,
- OPERATION_WRITE,
- OPERATION_CREATE,
- OPERATION_TRUNCATE
- };
-
- FileHelper(pp::Instance* instance,
- const std::string& file_path)
- : path_(file_path),
- instance_(instance),
- file_system_(NULL),
- file_ref_(NULL),
- file_io_(NULL),
- operation_(OPERATION_UNKNOWN) {
- }
-
- ~FileHelper() {
- if (file_io_)
- delete file_io_;
- if (file_ref_)
- delete file_ref_;
- if (file_system_)
- delete file_system_;
- }
-
- void TruncateFile() {
- operation_ = OPERATION_TRUNCATE;
- OpenFileSystem();
- }
-
- void ReadFromFile() {
- operation_ = OPERATION_READ;
- OpenFileSystem();
- }
-
- void WriteToFile(const std::string& data) {
- operation_ = OPERATION_WRITE;
- data_ = data;
- OpenFileSystem();
- }
-
- void CreateFile(const std::string& data) {
- operation_ = OPERATION_CREATE;
- data_ = data;
- OpenFileSystem();
- }
-
- private:
-
- struct ReadInfo {
- char buf[256];
- int32_t offset;
- FileHelper* self;
- std::string data;
- };
-
- void ReportError(const char* msg) {
- instance_->PostMessage(pp::Var(msg));
- delete this;
- }
-
- int GetFileOpenFlags() {
- switch (operation_) {
- case OPERATION_READ:
- return PP_FILEOPENFLAG_READ;
- case OPERATION_WRITE:
- return static_cast<int>(PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_READ);
- case OPERATION_CREATE:
- return static_cast<int>(PP_FILEOPENFLAG_CREATE |
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_READ |
- PP_FILEOPENFLAG_EXCLUSIVE);
- case OPERATION_TRUNCATE:
- return PP_FILEOPENFLAG_TRUNCATE | PP_FILEOPENFLAG_WRITE;
- case OPERATION_UNKNOWN:
- break;
- }
- return PP_FILEOPENFLAG_READ;
- }
-
- void OpenFileSystem() {
- file_system_ = new pp::FileSystem(instance_, PP_FILESYSTEMTYPE_EXTERNAL);
- file_system_->Open(4*1024*1024,
- pp::CompletionCallback(&OnFileSystemOpen, this));
- }
-
- void OpenFile() {
- file_io_ = new pp::FileIO(instance_);
- file_ref_ = new pp::FileRef(*file_system_, path_.c_str());
- file_io_->Open(*file_ref_, GetFileOpenFlags(),
- pp::CompletionCallback(&OnFileOpen, this));
- }
-
- void ProcessFile() {
- switch (operation_) {
- case OPERATION_READ:
- ProcessRead();
- break;
- case OPERATION_WRITE:
- ProcessWrite();
- break;
- case OPERATION_CREATE:
- ProcessWrite();
- break;
- case OPERATION_TRUNCATE:
- ProcessTruncate();
- break;
- case OPERATION_UNKNOWN:
- CompleteOperation(NULL, "FAIL");
- break;
- }
- }
-
- void ProcessWrite() {
- ReadInfo* info = new ReadInfo();
- info->self = this;
- info->data = data_;
- info->offset = 0;
- WriteChunk(info);
- }
-
- void WriteChunk(ReadInfo* info) {
- file_io_->Write(info->offset,
- info->data.c_str() + info->offset,
- info->data.length() - info->offset,
- pp::CompletionCallback(&WriteChunkCallback, info));
-
- }
-
- void ProcessRead() {
- ReadInfo* info = new ReadInfo();
- info->self = this;
- info->offset = 0;
- ReadChunk(info);
- }
-
- void ReadChunk(ReadInfo* info) {
- file_io_->Read(info->offset, info->buf, sizeof(info->buf),
- pp::CompletionCallback(&ReadChunkCallback, info));
- }
-
- void ProcessTruncate() {
- CompleteOperation(NULL, "OK");
- }
-
- void CompleteOperation(ReadInfo* info, const char* msg) {
- instance_->PostMessage(pp::Var(msg));
- file_io_->Close();
- if (info)
- delete info;
- delete this;
- }
-
- static void WriteChunkCallback(void* user_data, int32_t result) {
- ReadInfo* info = reinterpret_cast<ReadInfo*>(user_data);
- FileHelper* self = reinterpret_cast<FileHelper*>(info->self);
- if (result == 0) {
- self->CompleteOperation(info, "OK");
- } else if (result < 0) {
- self->CompleteOperation(info, "FAIL");
- } else {
- info->offset += result;
- self->WriteChunk(info);
- }
- }
-
- static void ReadChunkCallback(void* user_data, int32_t result) {
- ReadInfo* info = reinterpret_cast<ReadInfo*>(user_data);
- FileHelper* self = reinterpret_cast<FileHelper*>(info->self);
- if (result == 0) {
- self->CompleteOperation(info, info->data.c_str());
- } else if (result < 0) {
- self->CompleteOperation(info, "FAIL");
- } else {
- info->data.append(info->buf, result);
- info->offset += result;
- self->ReadChunk(info);
- }
- }
-
- static void OnFileSystemOpen(void* user_data, int32_t result) {
- FileHelper* self = reinterpret_cast<FileHelper*>(user_data);
- if (result != PP_OK) {
- self->ReportError("Failed to open file system.");
- return;
- }
-
- self->OpenFile();
- }
-
- static void OnFileOpen(void* user_data, int32_t result) {
- FileHelper* self = reinterpret_cast<FileHelper*>(user_data);
- if (result != PP_OK) {
- self->ReportError("Failed to open file.");
- return;
- }
- self->ProcessFile();
- }
-
- private:
- std::string path_;
- std::string data_;
- pp::Instance* instance_;
- pp::FileSystem* file_system_;
- pp::FileRef* file_ref_;
- pp::FileIO* file_io_;
- FileOperation operation_;
-};
-
-class FileHelperInstance : public pp::Instance {
- public:
- explicit FileHelperInstance(PP_Instance instance)
- : pp::Instance(instance) {}
- virtual ~FileHelperInstance() {}
-
- virtual void HandleMessage(const pp::Var& var_message);
-
-};
-
-void FileHelperInstance::HandleMessage(const pp::Var& var_message) {
- if (!var_message.is_string()) {
- return;
- }
- std::string message = var_message.AsString();
- std::vector<std::string> args;
- pp::Var return_var;
- Tokenize(message, std::string(kMessageArgumentSeparator), &args);
- if (args.size() < 2) {
- PostMessage(return_var);
- return;
- }
- const std::string& function = args[0];
- const std::string& file_path = args[1];
- FileHelper* helper = new FileHelper(this, file_path);
- if (function == kReadMethodId) {
- helper->ReadFromFile();
- return;
- } else if (function == kTruncateMethodId) {
- helper->TruncateFile();
- return;
- } else if (function == kWriteMethodId) {
- if (args.size() < 3) {
- PostMessage(return_var);
- return;
- }
- const std::string& data = args[2];
- helper->WriteToFile(data);
- return;
- } else if (function == kCreateMethodId) {
- if (args.size() < 3) {
- PostMessage(return_var);
- return;
- }
- const std::string& data = args[2];
- helper->CreateFile(data);
- return;
- }
- PostMessage(return_var);
-}
-
-class FileHelperModule : public pp::Module {
- public:
- FileHelperModule() : pp::Module() {}
- virtual ~FileHelperModule() {}
-
- virtual pp::Instance* CreateInstance(PP_Instance instance) {
- return new FileHelperInstance(instance);
- }
-};
-} // namespace file_reader
-
-
-namespace pp {
-Module* CreateModule() {
- return new file_reader::FileHelperModule();
-}
-} // namespace pp