12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef PPAPI_PROXY_URL_RESPONSE_INFO_RESOURCE_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define PPAPI_PROXY_URL_RESPONSE_INFO_RESOURCE_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/proxy/plugin_resource.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/proxy/ppapi_proxy_export.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/shared_impl/scoped_pp_resource.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/shared_impl/url_response_info_data.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ppapi/thunk/ppb_url_response_info_api.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace ppapi {
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace proxy {
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PPAPI_PROXY_EXPORT URLResponseInfoResource
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    : public PluginResource,
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      public NON_EXPORTED_BASE(thunk::PPB_URLResponseInfo_API) {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The file_ref_resource should be the body_as_file_ref host resource in the
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |data| converted to a resource valid in the current process (if we're
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // downloading to a file; it will be 0 if we're not). A reference
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // is passed from the caller and is taken over by this object.
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  URLResponseInfoResource(Connection connection,
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          PP_Instance instance,
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          const URLResponseInfoData& data,
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          PP_Resource file_ref_resource);
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~URLResponseInfoResource();
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Resource override.
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual PPB_URLResponseInfo_API* AsPPB_URLResponseInfo_API() OVERRIDE;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // PPB_URLResponseInfo_API implementation.
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual PP_Var GetProperty(PP_URLResponseProperty property) OVERRIDE;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual PP_Resource GetBodyAsFileRef() OVERRIDE;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  const URLResponseInfoData& data() const { return data_; }
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  URLResponseInfoData data_;
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Non-zero when the load is being streamed to a file.
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ScopedPPResource body_as_file_ref_;
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(URLResponseInfoResource);
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace proxy
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace ppapi
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // PPAPI_PROXY_URL_RESPONSE_INFO_RESOURCE_H_
55