Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ |
| 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "native_client/src/include/nacl_string.h" | 10 #include "native_client/src/include/nacl_string.h" |
| 11 #include "native_client/src/include/portability.h" | 11 #include "native_client/src/include/portability.h" |
| 12 | 12 |
| 13 namespace plugin { | 13 namespace plugin { |
| 14 | 14 |
| 15 // Options for PNaCl translation. | 15 // Options for PNaCl translation. |
| 16 class PnaclOptions { | 16 class PnaclOptions { |
| 17 | 17 |
| 18 public: | 18 public: |
| 19 PnaclOptions(); | 19 PnaclOptions(); |
| 20 ~PnaclOptions(); | 20 ~PnaclOptions(); |
| 21 | 21 |
| 22 // Return true if we know the hash of the bitcode, for caching. | 22 // Return |true| if PNaCl is allowed to cache. |
| 23 bool HasCacheKey() { return bitcode_hash_ != ""; } | 23 // PNaCl is allowed to cache if the server sends cache validators |
| 24 // like Last-Modified time or ETags in the HTTP response, and | |
| 25 // it does not send "Cache-Control: no-store". | |
| 26 bool HasCacheKey() const { return cache_validators_ != ""; } | |
|
dmichael (off chromium)
2013/06/14 16:21:43
nit: return (!cache_validators_.empty());
jvoung (off chromium)
2013/06/14 20:38:03
Done.
| |
| 24 | 27 |
| 25 // Return the cache key (which takes into account the bitcode hash, | 28 // Return the cache key (which takes into account the bitcode hash, |
| 26 // as well as the commandline options). | 29 // as well as the commandline options). |
| 27 nacl::string GetCacheKey(); | 30 nacl::string GetCacheKey() const; |
| 28 | 31 |
| 29 // Return true if the manifest did not specify any special options | 32 // Return true if the manifest did not specify any special options |
| 30 // (just using the default). | 33 // (just using the default). |
| 31 bool HasDefaultOpts() { | 34 bool HasDefaultOpts() const { |
| 32 return opt_level_ == -1 && experimental_flags_ == ""; | 35 return opt_level_ == -1 && experimental_flags_ == ""; |
|
dmichael (off chromium)
2013/06/14 16:21:43
experimental_flags_.empty();
jvoung (off chromium)
2013/06/14 20:38:03
Done.
| |
| 33 } | 36 } |
| 34 | 37 |
| 35 // Return a character array of \x00 delimited commandline options. | 38 // Return a character array of \x00 delimited commandline options. |
| 36 std::vector<char> GetOptCommandline(); | 39 std::vector<char> GetOptCommandline() const; |
| 37 | 40 |
| 38 bool translate() { return translate_; } | 41 bool translate() const { return translate_; } |
| 39 void set_translate(bool t) { translate_ = t; } | 42 void set_translate(bool t) { translate_ = t; } |
| 40 | 43 |
| 41 uint8_t opt_level() { return opt_level_; } | 44 uint8_t opt_level() const { return opt_level_; } |
| 42 void set_opt_level(int8_t l); | 45 void set_opt_level(int8_t l); |
| 43 | 46 |
| 44 nacl::string experimental_flags() { | 47 nacl::string experimental_flags() const { |
| 45 return experimental_flags_; | 48 return experimental_flags_; |
| 46 } | 49 } |
| 47 void set_experimental_flags(const nacl::string& f) { | 50 void set_experimental_flags(const nacl::string& f) { |
| 48 experimental_flags_ = f; | 51 experimental_flags_ = f; |
| 49 } | 52 } |
| 50 | 53 |
| 51 void set_bitcode_hash(const nacl::string& c) { | 54 void set_cache_validators(const nacl::string& c) { |
| 52 bitcode_hash_ = c; | 55 cache_validators_ = c; |
| 53 } | 56 } |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // NOTE: There are users of this class that use the copy constructor. | 59 // NOTE: There are users of this class that use the copy constructor. |
| 57 // Currently the default copy constructor is good enough, but | 60 // Currently the default copy constructor is good enough, but |
| 58 // double-check that it is the case when more fields are added. | 61 // double-check that it is the case when more fields are added. |
| 59 bool translate_; | 62 bool translate_; |
| 60 int8_t opt_level_; | 63 int8_t opt_level_; |
| 61 nacl::string experimental_flags_; | 64 nacl::string experimental_flags_; |
| 62 nacl::string bitcode_hash_; | 65 nacl::string cache_validators_; |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 } // namespace plugin; | 68 } // namespace plugin; |
| 66 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ | 69 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_ |
| OLD | NEW |