Home | History | Annotate | Download | only in plugin
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_
      6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_
      7 
      8 #include <vector>
      9 
     10 #include "native_client/src/include/nacl_string.h"
     11 #include "native_client/src/include/portability.h"
     12 
     13 namespace plugin {
     14 
     15 // Options for PNaCl translation.
     16 class PnaclOptions {
     17 
     18  public:
     19   PnaclOptions();
     20   ~PnaclOptions();
     21 
     22   // Return |true| if PNaCl is allowed to cache.
     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_.empty()); }
     27 
     28   // Return the cache key (which takes into account the bitcode hash,
     29   // as well as the commandline options).
     30   nacl::string GetCacheKey() const;
     31 
     32   // Return a character array of \x00 delimited commandline options.
     33   std::vector<char> GetOptCommandline() const;
     34 
     35   bool translate() const { return translate_; }
     36   void set_translate(bool t) { translate_ = t; }
     37 
     38   int32_t opt_level() const { return opt_level_; }
     39   void set_opt_level(int32_t l);
     40 
     41   void set_cache_validators(const nacl::string& c) {
     42     cache_validators_ = c;
     43   }
     44 
     45  private:
     46   // NOTE: There are users of this class that use the copy constructor.
     47   // Currently the default copy constructor is good enough, but
     48   // double-check that it is the case when more fields are added.
     49   bool translate_;
     50   int32_t opt_level_;
     51   nacl::string cache_validators_;
     52 };
     53 
     54 }  // namespace plugin;
     55 #endif  // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_OPTIONS_H_
     56