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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_uploader.h

Issue 9844006: GData downloads cleanup (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: asanka review feedback Created 8 years, 8 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) 2012 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 CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" 15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
16 #include "chrome/browser/chromeos/gdata/gdata_params.h" 16 #include "chrome/browser/chromeos/gdata/gdata_params.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 namespace content { 19 namespace content {
20 class DownloadItem; 20 class DownloadItem;
21 } 21 }
22 22
23 namespace gdata { 23 namespace gdata {
24 24
25 class DocumentsService;
26 class GDataFileSystem; 25 class GDataFileSystem;
27 struct UploadFileInfo; 26 struct UploadFileInfo;
28 27
29 class GDataUploader { 28 class GDataUploader {
30 public: 29 public:
31 explicit GDataUploader(GDataFileSystem* file_system); 30 explicit GDataUploader(GDataFileSystem* file_system);
32 virtual ~GDataUploader(); 31 virtual ~GDataUploader();
33 32
34 // Uploads a file specified by |upload_file_info|. Transfers ownership. 33 // Uploads a file specified by |upload_file_info|. Transfers ownership.
35 void UploadFile(UploadFileInfo* upload_file_info); 34 // Returns the upload_id.
35 int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info);
36 36
37 // Updates attributes of streaming upload. 37 // Updates attributes of streaming upload.
38 void UpdateUpload(int upload_id, content::DownloadItem* download); 38 void UpdateUpload(int upload_id, content::DownloadItem* download);
39 39
40 // Returns the count of bytes confirmed as uploaded so far. 40 // Returns the count of bytes confirmed as uploaded so far.
41 int64 GetUploadedBytes(int upload_id) const; 41 int64 GetUploadedBytes(int upload_id) const;
42 42
43 // TODO(achuith): Make this private.
44 // Destroys |upload_file_info|.
45 void DeleteUpload(UploadFileInfo* upload_file_info);
46
43 private: 47 private:
44 // Lookup UploadFileInfo* in pending_uploads_. 48 // Lookup UploadFileInfo* in pending_uploads_.
45 UploadFileInfo* GetUploadFileInfo(int upload_id) const; 49 UploadFileInfo* GetUploadFileInfo(int upload_id) const;
46 50
47 // Destroys |upload_file_info|.
48 void RemovePendingUpload(UploadFileInfo* upload_file_info);
49
50 // Open the file. 51 // Open the file.
51 void OpenFile(UploadFileInfo* upload_file_info); 52 void OpenFile(UploadFileInfo* upload_file_info);
52 53
53 // net::FileStream::Open completion callback. The result of the file 54 // net::FileStream::Open completion callback. The result of the file
54 // open operation is passed as |result|. 55 // open operation is passed as |result|.
55 void OpenCompletionCallback(int upload_id, int result); 56 void OpenCompletionCallback(int upload_id, int result);
56 57
57 // DocumentsService callback for InitiateUpload. 58 // DocumentsService callback for InitiateUpload.
58 void OnUploadLocationReceived(int upload_id, 59 void OnUploadLocationReceived(int upload_id,
59 GDataErrorCode code, 60 GDataErrorCode code,
60 const GURL& upload_location); 61 const GURL& upload_location);
61 62
62 // Uploads the next chunk of data from the file. 63 // Uploads the next chunk of data from the file.
63 void UploadNextChunk(UploadFileInfo* upload_file_info); 64 void UploadNextChunk(UploadFileInfo* upload_file_info);
64 65
65 // net::FileStream::Read completion callback. 66 // net::FileStream::Read completion callback.
66 void ReadCompletionCallback(int upload_id, 67 void ReadCompletionCallback(int upload_id,
67 int bytes_to_read, 68 int bytes_to_read,
68 int bytes_read); 69 int bytes_read);
69 70
70 // DocumentsService callback for ResumeUpload. 71 // DocumentsService callback for ResumeUpload.
71 void OnResumeUploadResponseReceived(int upload_id, 72 void OnResumeUploadResponseReceived(int upload_id,
72 const ResumeUploadResponse& response, 73 const ResumeUploadResponse& response,
73 scoped_ptr<DocumentEntry> entry); 74 scoped_ptr<DocumentEntry> entry);
74 75
75 // When upload completes, move the file into the gdata cache. 76 // When upload completes, move the file into the gdata cache.
76 void UploadComplete(UploadFileInfo* upload_file_info); 77 void MoveFileToCache(UploadFileInfo* upload_file_info);
78
79 // Handle failed uploads.
80 void UploadFailed(UploadFileInfo* upload_file_info);
77 81
78 // Private data. 82 // Private data.
79 GDataFileSystem* file_system_; 83 GDataFileSystem* file_system_;
80 84
81 int next_upload_id_; // id counter. 85 int next_upload_id_; // id counter.
86
82 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap; 87 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap;
83 UploadFileInfoMap pending_uploads_; 88 UploadFileInfoMap pending_uploads_;
84 89
85 // Factory for various callbacks. 90 // Factory for various callbacks.
86 base::WeakPtrFactory<GDataUploader> uploader_factory_; 91 base::WeakPtrFactory<GDataUploader> uploader_factory_;
87 92
88 DISALLOW_COPY_AND_ASSIGN(GDataUploader); 93 DISALLOW_COPY_AND_ASSIGN(GDataUploader);
89 }; 94 };
90 95
91 } // namespace gdata 96 } // namespace gdata
92 97
93 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 98 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_upload_file_info.h ('k') | chrome/browser/chromeos/gdata/gdata_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698