summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/download_types.h
blob: 56d07af858b3cf95e0d66ca8e5fe73c5c085e9e8 (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
// Copyright (c) 2010 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_BROWSER_DOWNLOAD_DOWNLOAD_TYPES_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TYPES_H_
#pragma once

#include <vector>

#include "base/file_path.h"
#include "base/linked_ptr.h"
#include "base/synchronization/lock.h"
#include "net/base/file_stream.h"

namespace net {
class IOBuffer;
}

// DownloadBuffer is created and populated on the IO thread, and passed to the
// file thread for writing. In order to avoid flooding the file thread with too
// many small write messages, each write is appended to the DownloadBuffer while
// waiting for the task to run on the file thread. Access to the write buffers
// is synchronized via the lock. Each entry in 'contents' represents one data
// buffer and its size in bytes.
struct DownloadBuffer {
  DownloadBuffer();
  ~DownloadBuffer();

  base::Lock lock;
  typedef std::pair<net::IOBuffer*, int> Contents;
  std::vector<Contents> contents;
};

// Holds the information about how to save a download file.
struct DownloadSaveInfo {
  DownloadSaveInfo();
  DownloadSaveInfo(const DownloadSaveInfo& info);
  ~DownloadSaveInfo();
  DownloadSaveInfo& operator=(const DownloadSaveInfo& info);

  FilePath file_path;
  linked_ptr<net::FileStream> file_stream;
};

#endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TYPES_H_