| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can | |
| 4 * be found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_RESOURCE_H_ | |
| 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_RESOURCE_H_ | |
| 9 | |
| 10 #include "native_client/src/include/nacl_macros.h" | |
| 11 #include "ppapi/c/ppb_url_response_info.h" | |
| 12 | |
| 13 namespace fake_browser_ppapi { | |
| 14 | |
| 15 class URLLoader; | |
| 16 class URLRequestInfo; | |
| 17 class URLResponseInfo; | |
| 18 class FileIO; | |
| 19 class FileRef; | |
| 20 | |
| 21 // Represents a generic resource tracked by the Host. | |
| 22 // The C API functions usually start by mapping a PP_Resource id to a Resource | |
| 23 // and then access and modify its state. | |
| 24 // This is a simplified version of Chrome's pepper::Resource. | |
| 25 class Resource { | |
| 26 public: | |
| 27 Resource() : resource_id_(0) {} | |
| 28 virtual ~Resource() {} | |
| 29 | |
| 30 void set_resource_id(PP_Resource resource_id) { resource_id_ = resource_id; } | |
| 31 PP_Resource resource_id() const { return resource_id_; } | |
| 32 | |
| 33 // This will allow us to safely cast Resource to derived types. | |
| 34 // The derived classes must therefore override their respective methods to | |
| 35 // return |this|. | |
| 36 virtual URLLoader* AsURLLoader() { return NULL; } | |
| 37 virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } | |
| 38 virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } | |
| 39 virtual FileIO* AsFileIO() { return NULL; } | |
| 40 virtual FileRef* AsFileRef() { return NULL; } | |
| 41 | |
| 42 static Resource* Invalid() { return &kInvalidResource; } | |
| 43 | |
| 44 private: | |
| 45 PP_Resource resource_id_; | |
| 46 | |
| 47 static Resource kInvalidResource; | |
| 48 NACL_DISALLOW_COPY_AND_ASSIGN(Resource); | |
| 49 }; | |
| 50 | |
| 51 // These are made global so that C API functions can access them from any file. | |
| 52 // To be implemented by main.cc. | |
| 53 PP_Resource TrackResource(Resource* resource); | |
| 54 // Returns Resource::Invalid() on error. | |
| 55 Resource* GetResource(PP_Resource resource_id); | |
| 56 | |
| 57 } // namespace fake_browser_ppapi | |
| 58 | |
| 59 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_RESOURCE_H_ | |
| OLD | NEW |