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

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

Issue 10640006: gdata: Stop getting GDataUploader via GDataSystemService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 "base/platform_file.h" 15 #include "base/platform_file.h"
16 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" 16 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
17 #include "chrome/browser/chromeos/gdata/gdata_params.h" 17 #include "chrome/browser/chromeos/gdata/gdata_params.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 19
20 namespace content { 20 namespace content {
21 class DownloadItem; 21 class DownloadItem;
22 } 22 }
23 23
24 namespace gdata { 24 namespace gdata {
25 25
26 class GDataFileSystem; 26 class GDataFileSystem;
27 class DocumentsServiceInterface; 27 class DocumentsServiceInterface;
28 struct UploadFileInfo; 28 struct UploadFileInfo;
29 29
30 class GDataUploader { 30 class GDataUploaderInterface {
31 public: 31 public:
32 explicit GDataUploader(GDataFileSystem* file_system, 32 ~GDataUploaderInterface() {}
33 DocumentsServiceInterface* documents_service);
34 virtual ~GDataUploader();
35 33
36 // Uploads a file specified by |upload_file_info|. Transfers ownership. 34 // Uploads a file specified by |upload_file_info|. Transfers ownership.
37 // Returns the upload_id. 35 // Returns the upload_id.
38 int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info); 36 //
37 // WARNING: This is not mockable by gmock because it takes scoped_ptr<>.
38 // See "Announcing scoped_ptr<>::Pass(). The latest in pointer ownership
39 // technology!" thread on chromium-dev.
40 virtual int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info) = 0;
39 41
40 // Updates attributes of streaming upload. 42 // Updates attributes of streaming upload.
41 void UpdateUpload(int upload_id, content::DownloadItem* download); 43 virtual void UpdateUpload(int upload_id,
44 content::DownloadItem* download) = 0;
42 45
43 // Returns the count of bytes confirmed as uploaded so far. 46 // Returns the count of bytes confirmed as uploaded so far.
44 int64 GetUploadedBytes(int upload_id) const; 47 virtual int64 GetUploadedBytes(int upload_id) const = 0;
48 };
49
50 class GDataUploader : public GDataUploaderInterface {
51 public:
52 explicit GDataUploader(DocumentsServiceInterface* documents_service);
53 virtual ~GDataUploader();
54
55 // Sets the file system. This must be called before calling other member
56 // functions.
57 //
58 // TODO(satorux): The dependency to GDataFileSystem should be
59 // eliminated. http://crbug.com/133860
60 void set_file_system(GDataFileSystem* file_system) {
61 file_system_ = file_system;
62 }
63
64 // GDataUploaderInterface overrides.
65 virtual int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info);
66 virtual void UpdateUpload(int upload_id, content::DownloadItem* download);
67 virtual int64 GetUploadedBytes(int upload_id) const;
45 68
46 private: 69 private:
47 // Lookup UploadFileInfo* in pending_uploads_. 70 // Lookup UploadFileInfo* in pending_uploads_.
48 UploadFileInfo* GetUploadFileInfo(int upload_id) const; 71 UploadFileInfo* GetUploadFileInfo(int upload_id) const;
49 72
50 // Open the file. 73 // Open the file.
51 void OpenFile(UploadFileInfo* upload_file_info); 74 void OpenFile(UploadFileInfo* upload_file_info);
52 75
53 // net::FileStream::Open completion callback. The result of the file 76 // net::FileStream::Open completion callback. The result of the file
54 // open operation is passed as |result|. 77 // open operation is passed as |result|.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 120
98 // Factory for various callbacks. 121 // Factory for various callbacks.
99 base::WeakPtrFactory<GDataUploader> uploader_factory_; 122 base::WeakPtrFactory<GDataUploader> uploader_factory_;
100 123
101 DISALLOW_COPY_AND_ASSIGN(GDataUploader); 124 DISALLOW_COPY_AND_ASSIGN(GDataUploader);
102 }; 125 };
103 126
104 } // namespace gdata 127 } // namespace gdata
105 128
106 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 129 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698