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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc

Issue 2156503002: [NaCl SDK] Expose Google Drive to nacl_io. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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: native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc b/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..697eeab0240b35daa891499da64d75152d866367
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 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 "fake_ppapi/fake_file_system_interface.h"
+
+#include <algorithm>
+
+#include <ppapi/c/pp_completion_callback.h>
+#include <ppapi/c/pp_errors.h>
+
+#include "gtest/gtest.h"
+
+#include "fake_ppapi/fake_core_interface.h"
+#include "fake_ppapi/fake_filesystem.h"
+#include "fake_ppapi/fake_util.h"
+
+namespace {
+
+class FakeInstanceResource : public FakeResource {
+ public:
+ FakeInstanceResource() : filesystem_template(NULL) {}
+ static const char* classname() { return "FakeInstanceResource"; }
+
+ FakeFilesystem* filesystem_template; // Weak reference.
+};
+
+} // namespace
+
+FakeFileSystemInterface::FakeFileSystemInterface(
+ FakeCoreInterface* core_interface)
+ : core_interface_(core_interface) {}
+
+PP_Bool FakeFileSystemInterface::IsFileSystem(PP_Resource resource) {
+ bool not_found_ok = true;
+ FakeFileSystemResource* file_system_resource =
+ core_interface_->resource_manager()->Get<FakeFileSystemResource>(
+ resource, not_found_ok);
+ return file_system_resource != NULL ? PP_TRUE : PP_FALSE;
+}
+
+PP_Resource FakeFileSystemInterface::Create(PP_Instance instance,
+ PP_FileSystemType filesystem_type) {
+ FakeInstanceResource* instance_resource =
+ core_interface_->resource_manager()->Get<FakeInstanceResource>(instance);
+ if (instance_resource == NULL)
+ return PP_ERROR_BADRESOURCE;
+
+ FakeFileSystemResource* file_system_resource = new FakeFileSystemResource;
+ file_system_resource->filesystem = new FakeFilesystem(
+ *instance_resource->filesystem_template, filesystem_type);
+
+ return CREATE_RESOURCE(core_interface_->resource_manager(),
+ FakeFileSystemResource, file_system_resource);
+}
+
+int32_t FakeFileSystemInterface::Open(PP_Resource file_system,
+ int64_t expected_size,
+ PP_CompletionCallback callback) {
+ FakeFileSystemResource* file_system_resource =
+ core_interface_->resource_manager()->Get<FakeFileSystemResource>(
+ file_system);
+ if (file_system_resource == NULL)
+ return PP_ERROR_BADRESOURCE;
+
+ file_system_resource->opened = true;
+ return RunCompletionCallback(&callback, PP_OK);
+}

Powered by Google App Engine
This is Rietveld 408576698