Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: content/public/browser/download_id.h

Issue 9426029: Test file errors in downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored per Chris & Randy's comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_
7 #pragma once 7 #pragma once
8 8
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <string> 10 #include <string>
11 11
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // DownloadId combines per-profile Download ids with an indication of which 18 // DownloadId combines per-profile Download ids with an indication of which
19 // profile in order to be globally unique. DownloadIds are not persistent across 19 // profile in order to be globally unique. DownloadIds are not persistent across
20 // sessions, but their local() field is. 20 // sessions, but their local() field is.
21 class DownloadId { 21 class DownloadId {
22 public: 22 public:
23 static DownloadId Invalid() { return DownloadId(NULL, -1); } 23 static DownloadId Invalid() { return DownloadId(); }
24 24
25 // Domain separates spaces of local ids. 25 // Domain separates spaces of local ids.
26 typedef const void* Domain; 26 typedef const void* Domain;
27 27
28 DownloadId() : domain_(NULL), local_id_(-1) {}
29
28 DownloadId(Domain domain, int32 local_id) 30 DownloadId(Domain domain, int32 local_id)
29 : domain_(domain), 31 : domain_(domain),
30 local_id_(local_id) { 32 local_id_(local_id) {
31 } 33 }
32 34
33 // Return the per-profile and persistent part of this DownloadId. 35 // Return the per-profile and persistent part of this DownloadId.
34 int32 local() const { return local_id_; } 36 int32 local() const { return local_id_; }
35 37
36 // Returns true if this DownloadId has been allocated and could possibly refer 38 // Returns true if this DownloadId has been allocated and could possibly refer
37 // to a DownloadItem that exists. 39 // to a DownloadItem that exists.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return id.hash(); 94 return id.hash();
93 } 95 }
94 }; 96 };
95 #elif defined(COMPILER_MSVC) 97 #elif defined(COMPILER_MSVC)
96 inline size_t hash_value(const content::DownloadId& id) { 98 inline size_t hash_value(const content::DownloadId& id) {
97 return id.hash(); 99 return id.hash();
98 } 100 }
99 #endif // COMPILER 101 #endif // COMPILER
100 } 102 }
101 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ 103 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698