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

Side by Side Diff: chrome/browser/chromeos/policy/upload_job_impl.h

Issue 1547593002: Introducing a net::GenerateMimeMultipartBoundary helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_POLICY_UPLOAD_JOB_IMPL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_UPLOAD_JOB_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_UPLOAD_JOB_IMPL_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_UPLOAD_JOB_IMPL_H_
7 7
8 #include <stddef.h>
9
10 #include <map> 8 #include <map>
11 #include <string> 9 #include <string>
12 10
13 #include "base/macros.h" 11 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
17 #include "chrome/browser/chromeos/policy/upload_job.h" 15 #include "chrome/browser/chromeos/policy/upload_job.h"
18 #include "google_apis/gaia/oauth2_token_service.h" 16 #include "google_apis/gaia/oauth2_token_service.h"
19 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
20 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
21 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
22 #include "url/gurl.h" 20 #include "url/gurl.h"
23 21
24 namespace policy { 22 namespace policy {
25 23
26 // This implementation of UploadJob uses the OAuth2TokenService to acquire 24 // This implementation of UploadJob uses the OAuth2TokenService to acquire
27 // access tokens for the device management (cloud-based policy) server scope and 25 // access tokens for the device management (cloud-based policy) server scope and
28 // uses a URLFetcher to upload data to the specified upload url. 26 // uses a URLFetcher to upload data to the specified upload url.
29 class UploadJobImpl : public UploadJob, 27 class UploadJobImpl : public UploadJob,
30 public OAuth2TokenService::Consumer, 28 public OAuth2TokenService::Consumer,
31 public net::URLFetcherDelegate { 29 public net::URLFetcherDelegate {
32 public: 30 public:
33 // UploadJobImpl uses a MimeBoundaryGenerator to generate strings which 31 // UploadJobImpl uses a MimeBoundaryGenerator to generate strings which
34 // mark the boundaries between data segments. 32 // mark the boundaries between data segments.
35 class MimeBoundaryGenerator { 33 class MimeBoundaryGenerator {
36 public: 34 public:
37 virtual ~MimeBoundaryGenerator(); 35 virtual ~MimeBoundaryGenerator();
38 36
39 virtual std::string GenerateBoundary(size_t length) const = 0; 37 virtual std::string GenerateBoundary() const = 0;
40 38
41 private: 39 private:
42 DISALLOW_ASSIGN(MimeBoundaryGenerator); 40 DISALLOW_ASSIGN(MimeBoundaryGenerator);
43 }; 41 };
44 42
45 // An implemenation of the MimeBoundaryGenerator which uses random 43 // An implemenation of the MimeBoundaryGenerator which uses random
46 // alpha-numeric characters to construct MIME boundaries. 44 // alpha-numeric characters to construct MIME boundaries.
47 class RandomMimeBoundaryGenerator : public MimeBoundaryGenerator { 45 class RandomMimeBoundaryGenerator : public MimeBoundaryGenerator {
48 public: 46 public:
49 ~RandomMimeBoundaryGenerator() override; 47 ~RandomMimeBoundaryGenerator() override;
50 48
51 std::string GenerateBoundary( 49 std::string GenerateBoundary() const override; // MimeBoundaryGenerator
52 size_t length) const override; // MimeBoundaryGenerator
53 }; 50 };
54 51
55 UploadJobImpl(const GURL& upload_url, 52 UploadJobImpl(const GURL& upload_url,
56 const std::string& account_id, 53 const std::string& account_id,
57 OAuth2TokenService* token_service, 54 OAuth2TokenService* token_service,
58 scoped_refptr<net::URLRequestContextGetter> url_context_getter, 55 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
59 Delegate* delegate, 56 Delegate* delegate,
60 scoped_ptr<MimeBoundaryGenerator> boundary_generator); 57 scoped_ptr<MimeBoundaryGenerator> boundary_generator);
61 ~UploadJobImpl() override; 58 ~UploadJobImpl() override;
62 59
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 146
150 // The data chunks to be uploaded. 147 // The data chunks to be uploaded.
151 ScopedVector<DataSegment> data_segments_; 148 ScopedVector<DataSegment> data_segments_;
152 149
153 DISALLOW_COPY_AND_ASSIGN(UploadJobImpl); 150 DISALLOW_COPY_AND_ASSIGN(UploadJobImpl);
154 }; 151 };
155 152
156 } // namespace policy 153 } // namespace policy
157 154
158 #endif // CHROME_BROWSER_CHROMEOS_POLICY_UPLOAD_JOB_IMPL_H_ 155 #endif // CHROME_BROWSER_CHROMEOS_POLICY_UPLOAD_JOB_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698