summaryrefslogtreecommitdiffstats
path: root/chrome_frame/urlmon_upload_data_stream.h
blob: 30b72716269c2496712d1c22d933c6be05528288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_FRAME_URLMON_UPLOAD_DATA_STREAM_H_
#define CHROME_FRAME_URLMON_UPLOAD_DATA_STREAM_H_

#include <urlmon.h>
#include <atlbase.h>
#include <atlcom.h>

#include "base/logging.h"
#include "base/ref_counted.h"

#include "net/base/upload_data.h"
#include "net/base/upload_data_stream.h"

// Provides an IStream interface to the very different UploadDataStream
// implementation.
class UrlmonUploadDataStream : public CComObjectRootEx<CComMultiThreadModel>,
                               public IStream {
 public:
  UrlmonUploadDataStream() {}

  BEGIN_COM_MAP(UrlmonUploadDataStream)
    COM_INTERFACE_ENTRY(ISequentialStream)
    COM_INTERFACE_ENTRY(IStream)
  END_COM_MAP()

  void Initialize(net::UploadData* upload_data);

  // Partial implementation of IStream.
  STDMETHOD(Read)(void* pv, ULONG cb, ULONG* read);

  // E_NOTIMPL the rest and DCHECK if they get called (could also use
  // IStreamImpl but we'd lose the DCHECKS().
  STDMETHOD(Write)(const void * buffer, ULONG size, ULONG* size_written) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(CopyTo)(IStream* stream, ULARGE_INTEGER cb, ULARGE_INTEGER* read,
                    ULARGE_INTEGER* written) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(Seek)(LARGE_INTEGER move, DWORD origin, ULARGE_INTEGER* new_pos);

  STDMETHOD(SetSize)(ULARGE_INTEGER new_size) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(Commit)(DWORD flags) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(Revert)() {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(LockRegion)(ULARGE_INTEGER offset, ULARGE_INTEGER cb,
                        DWORD type) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(UnlockRegion)(ULARGE_INTEGER offset, ULARGE_INTEGER cb,
                          DWORD type) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

  STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);

  STDMETHOD(Clone)(IStream** stream) {
    DCHECK(false) << __FUNCTION__;
    return E_NOTIMPL;
  }

 private:
  scoped_refptr<net::UploadData> upload_data_;
  scoped_ptr<net::UploadDataStream> request_body_stream_;
};

#endif  // CHROME_FRAME_URLMON_UPLOAD_DATA_STREAM_H_