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

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

Issue 2455973003: [NaCl SDK] Refactor FakeFileSystemInterface. (Closed)
Patch Set: Created 4 years, 1 month 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..52f90d69e4956f69ed3dfb43ef7af0d025b4bec3
--- /dev/null
+++ b/native_client_sdk/src/tests/nacl_io_test/fake_ppapi/fake_file_system_interface.cc
@@ -0,0 +1,52 @@
+// 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 <ppapi/c/pp_completion_callback.h>
+#include <ppapi/c/pp_errors.h>
+
+#include "fake_ppapi/fake_core_interface.h"
+#include "fake_ppapi/fake_pepper_interface_html5_fs.h"
+#include "fake_ppapi/fake_util.h"
+
+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) {
+ FakeHtml5FsResource* instance_resource =
+ core_interface_->resource_manager()->Get<FakeHtml5FsResource>(instance);
+ if (instance_resource == NULL)
+ return PP_ERROR_BADRESOURCE;
+
+ FakeFileSystemResource* file_system_resource = new FakeFileSystemResource;
+ file_system_resource->filesystem = new FakeHtml5FsFilesystem(
+ *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