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

Side by Side Diff: ppapi/tests/test_file_io.cc

Issue 8764003: Implement a proxy for Pepper FileIO. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/tests/test_file_io.h" 5 #include "ppapi/tests/test_file_io.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ppapi/c/dev/ppb_testing_dev.h" 10 #include "ppapi/c/dev/ppb_testing_dev.h"
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 if (rv == PP_OK_COMPLETIONPENDING) 934 if (rv == PP_OK_COMPLETIONPENDING)
935 rv = callback.WaitForResult(); 935 rv = callback.WaitForResult();
936 if (rv != PP_OK) 936 if (rv != PP_OK)
937 return ReportError("FileIO::Open", rv); 937 return ReportError("FileIO::Open", rv);
938 938
939 const PPB_FileIOTrusted* trusted = static_cast<const PPB_FileIOTrusted*>( 939 const PPB_FileIOTrusted* trusted = static_cast<const PPB_FileIOTrusted*>(
940 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); 940 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE));
941 if (!trusted) 941 if (!trusted)
942 return ReportError("FileIOTrusted", PP_ERROR_FAILED); 942 return ReportError("FileIOTrusted", PP_ERROR_FAILED);
943 943
944 // Get file descriptor. 944 // Get file descriptor. This is only supported in-process for now, so don't
945 int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource()); 945 // test out of process.
946 if (fd < 0) 946 const PPB_Testing_Dev* testing_interface = GetTestingInterface();
947 return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; 947 if (testing_interface && !testing_interface->IsOutOfProcess()) {
948 int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource());
949 if (fd < 0)
950 return "FileIO::GetOSFileDescriptor() returned a bad file descriptor.";
951 }
948 952
949 // Calling WillWrite. 953 // Calling WillWrite.
950 rv = trusted->WillWrite( 954 rv = trusted->WillWrite(
951 file_io.pp_resource(), 0, 9, 955 file_io.pp_resource(), 0, 9,
952 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); 956 static_cast<pp::CompletionCallback>(callback).pp_completion_callback());
953 if (rv == PP_OK_COMPLETIONPENDING) 957 if (rv == PP_OK_COMPLETIONPENDING)
954 rv = callback.WaitForResult(); 958 rv = callback.WaitForResult();
955 if (rv != 9) 959 if (rv != 9)
956 return ReportError("WillWrite", rv); 960 return ReportError("WillWrite", rv);
957 961
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 rv = callback.WaitForResult(); 1095 rv = callback.WaitForResult();
1092 if ((invalid_combination && rv == PP_OK) || 1096 if ((invalid_combination && rv == PP_OK) ||
1093 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { 1097 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) {
1094 return ReportOpenError(open_flags); 1098 return ReportOpenError(open_flags);
1095 } 1099 }
1096 1100
1097 return std::string(); 1101 return std::string();
1098 } 1102 }
1099 1103
1100 // TODO(viettrungluu): Test Close(). crbug.com/69457 1104 // TODO(viettrungluu): Test Close(). crbug.com/69457
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698