request_util.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "google_apis/drive/request_util.h"
  5. #include <string>
  6. #include "base/values.h"
  7. namespace google_apis {
  8. namespace util {
  9. namespace {
  10. // etag matching header.
  11. const char kIfMatchHeaderPrefix[] = "If-Match: ";
  12. const char kParentLinkKind[] = "drive#fileLink";
  13. } // namespace
  14. const char kIfMatchAllHeader[] = "If-Match: *";
  15. const char kContentTypeApplicationJson[] = "application/json";
  16. std::string GenerateIfMatchHeader(const std::string& etag) {
  17. return etag.empty() ? kIfMatchAllHeader : (kIfMatchHeaderPrefix + etag);
  18. }
  19. std::unique_ptr<base::DictionaryValue> CreateParentValue(
  20. const std::string& file_id) {
  21. std::unique_ptr<base::DictionaryValue> parent(new base::DictionaryValue);
  22. parent->SetString("kind", kParentLinkKind);
  23. parent->SetString("id", file_id);
  24. return parent;
  25. }
  26. } // namespace util
  27. } // namespace google_apis