OLD | NEW |
---|---|
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 #include "components/sync/driver/sync_stopped_reporter.h" | 5 #include "components/sync/driver/sync_stopped_reporter.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "components/data_use_measurement/core/data_use_user_data.h" | 12 #include "components/data_use_measurement/core/data_use_user_data.h" |
13 #include "components/sync/protocol/sync.pb.h" | 13 #include "components/sync/protocol/sync.pb.h" |
14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
15 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
16 #include "net/traffic_annotation/network_traffic_annotation.h" | |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const char kEventEndpoint[] = "event"; | 20 const char kEventEndpoint[] = "event"; |
20 | 21 |
21 // The request is tiny, so even on poor connections 10 seconds should be | 22 // The request is tiny, so even on poor connections 10 seconds should be |
22 // plenty of time. Since sync is off when this request is started, we don't | 23 // plenty of time. Since sync is off when this request is started, we don't |
23 // want anything sync-related hanging around for very long from a human | 24 // want anything sync-related hanging around for very long from a human |
24 // perspective either. This seems like a good compromise. | 25 // perspective either. This seems like a good compromise. |
25 const int kRequestTimeoutSeconds = 10; | 26 const int kRequestTimeoutSeconds = 10; |
(...skipping 28 matching lines...) Expand all Loading... | |
54 // Make the request proto with the GUID identifying this client. | 55 // Make the request proto with the GUID identifying this client. |
55 sync_pb::EventRequest event_request; | 56 sync_pb::EventRequest event_request; |
56 sync_pb::SyncDisabledEvent* sync_disabled_event = | 57 sync_pb::SyncDisabledEvent* sync_disabled_event = |
57 event_request.mutable_sync_disabled(); | 58 event_request.mutable_sync_disabled(); |
58 sync_disabled_event->set_cache_guid(cache_guid); | 59 sync_disabled_event->set_cache_guid(cache_guid); |
59 sync_disabled_event->set_store_birthday(birthday); | 60 sync_disabled_event->set_store_birthday(birthday); |
60 | 61 |
61 std::string msg; | 62 std::string msg; |
62 event_request.SerializeToString(&msg); | 63 event_request.SerializeToString(&msg); |
63 | 64 |
64 fetcher_ = | 65 net::NetworkTrafficAnnotationTag traffic_annotation = |
65 net::URLFetcher::Create(sync_event_url_, net::URLFetcher::POST, this); | 66 net::DefineNetworkTrafficAnnotation("...", R"( |
Nicolas Zea
2017/02/23 22:15:54
It would be nice if we didn't have to repeat this
Ramin Halavati
2017/02/24 07:53:03
Please elaborate me if I didn't understand your co
Nicolas Zea
2017/02/24 20:37:38
I was just thinking have the R"..." string be save
Ramin Halavati
2017/02/27 09:23:16
Current plan is extraction of R"..." strings using
| |
67 semantics { | |
68 sender: "..." | |
Nicolas Zea
2017/03/03 22:39:55
sender: "chrome sync"
description: "A network requ
Ramin Halavati
2017/03/06 06:55:45
Thanks, could you elaborate on "Store Birthday"
C
Nicolas Zea
2017/03/06 17:49:20
Store birthday is the identifier for the lifetime
Ramin Halavati
2017/03/07 08:53:47
Done.
| |
69 description: "..." | |
70 trigger: "..." | |
71 data: "..." | |
72 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
73 } | |
74 policy { | |
75 cookies_allowed: false/true | |
76 cookies_store: "..." | |
77 setting: "..." | |
78 policy { | |
79 [POLICY_NAME] { | |
80 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
81 value: ... | |
82 } | |
83 } | |
84 policy_exception_justification: "..." | |
85 })"); | |
86 fetcher_ = net::URLFetcher::Create(sync_event_url_, net::URLFetcher::POST, | |
87 this, traffic_annotation); | |
66 fetcher_->AddExtraRequestHeader(base::StringPrintf( | 88 fetcher_->AddExtraRequestHeader(base::StringPrintf( |
67 "%s: Bearer %s", net::HttpRequestHeaders::kAuthorization, | 89 "%s: Bearer %s", net::HttpRequestHeaders::kAuthorization, |
68 access_token.c_str())); | 90 access_token.c_str())); |
69 fetcher_->AddExtraRequestHeader(base::StringPrintf( | 91 fetcher_->AddExtraRequestHeader(base::StringPrintf( |
70 "%s: %s", net::HttpRequestHeaders::kUserAgent, user_agent_.c_str())); | 92 "%s: %s", net::HttpRequestHeaders::kUserAgent, user_agent_.c_str())); |
71 fetcher_->SetRequestContext(request_context_.get()); | 93 fetcher_->SetRequestContext(request_context_.get()); |
72 fetcher_->SetUploadData("application/octet-stream", msg); | 94 fetcher_->SetUploadData("application/octet-stream", msg); |
73 fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | | 95 fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | |
74 net::LOAD_DO_NOT_SAVE_COOKIES | | 96 net::LOAD_DO_NOT_SAVE_COOKIES | |
75 net::LOAD_DO_NOT_SEND_COOKIES); | 97 net::LOAD_DO_NOT_SEND_COOKIES); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 replacements.SetPathStr(path); | 132 replacements.SetPathStr(path); |
111 return sync_service_url.ReplaceComponents(replacements); | 133 return sync_service_url.ReplaceComponents(replacements); |
112 } | 134 } |
113 | 135 |
114 void SyncStoppedReporter::SetTimerTaskRunnerForTest( | 136 void SyncStoppedReporter::SetTimerTaskRunnerForTest( |
115 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 137 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
116 timer_.SetTaskRunner(task_runner); | 138 timer_.SetTaskRunner(task_runner); |
117 } | 139 } |
118 | 140 |
119 } // namespace syncer | 141 } // namespace syncer |
OLD | NEW |