Split fx_guid from fx_extension

This CL splits the GUID code out of fx_extension into an fx_guid.h file.

Change-Id: I915538ff98601efb07595264eff6435729193177
Reviewed-on: https://pdfium-review.googlesource.com/13090
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 59804a7..2d226da 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -944,6 +944,8 @@
       "core/fxcrt/css/cfx_cssvaluelistparser.h",
       "core/fxcrt/fx_arabic.cpp",
       "core/fxcrt/fx_arabic.h",
+      "core/fxcrt/fx_guid.cpp",
+      "core/fxcrt/fx_guid.h",
       "core/fxcrt/ifx_chariter.h",
       "core/fxcrt/ifx_locale.h",
       "core/fxcrt/xml/cfx_saxcontext.cpp",
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 35a8442..7f73a4c 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -9,8 +9,6 @@
 #include <algorithm>
 #include <cwctype>
 
-#include "core/fxcrt/fx_rand.h"
-
 float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) {
   ASSERT(pwsStr);
   if (iLength < 0)
@@ -124,28 +122,6 @@
   return 8;
 }
 
-#ifdef PDF_ENABLE_XFA
-void FX_GUID_CreateV4(FX_GUID* pGUID) {
-  FX_Random_GenerateMT((uint32_t*)pGUID, 4);
-  uint8_t& b = ((uint8_t*)pGUID)[6];
-  b = (b & 0x0F) | 0x40;
-}
-
-CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator) {
-  CFX_ByteString bsStr;
-  char* pBuf = bsStr.GetBuffer(40);
-  for (int32_t i = 0; i < 16; i++) {
-    uint8_t b = reinterpret_cast<const uint8_t*>(pGUID)[i];
-    FXSYS_IntToTwoHexChars(b, pBuf);
-    pBuf += 2;
-    if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9))
-      *pBuf++ = L'-';
-  }
-  bsStr.ReleaseBuffer(bSeparator ? 36 : 32);
-  return bsStr;
-}
-#endif  // PDF_ENABLE_XFA
-
 uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) {
   ASSERT(0 < nbits && nbits <= 32);
   const uint8_t* dataPtr = &pData[bitpos / 8];
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index 365ab4d..e02d58d 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -86,18 +86,6 @@
 
 size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf);
 
-
-#ifdef PDF_ENABLE_XFA
-struct FX_GUID {
-  uint32_t data1;
-  uint16_t data2;
-  uint16_t data3;
-  uint8_t data4[8];
-};
-void FX_GUID_CreateV4(FX_GUID* pGUID);
-CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator = true);
-#endif  // PDF_ENABLE_XFA
-
 uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits);
 
 #endif  // CORE_FXCRT_FX_EXTENSION_H_
diff --git a/core/fxcrt/fx_guid.cpp b/core/fxcrt/fx_guid.cpp
new file mode 100644
index 0000000..6f130f9
--- /dev/null
+++ b/core/fxcrt/fx_guid.cpp
@@ -0,0 +1,30 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxcrt/fx_guid.h"
+
+#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_rand.h"
+
+void FX_GUID_CreateV4(FX_GUID* pGUID) {
+  FX_Random_GenerateMT((uint32_t*)pGUID, 4);
+  uint8_t& b = ((uint8_t*)pGUID)[6];
+  b = (b & 0x0F) | 0x40;
+}
+
+CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator) {
+  CFX_ByteString bsStr;
+  char* pBuf = bsStr.GetBuffer(40);
+  for (int32_t i = 0; i < 16; i++) {
+    uint8_t b = reinterpret_cast<const uint8_t*>(pGUID)[i];
+    FXSYS_IntToTwoHexChars(b, pBuf);
+    pBuf += 2;
+    if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9))
+      *pBuf++ = L'-';
+  }
+  bsStr.ReleaseBuffer(bSeparator ? 36 : 32);
+  return bsStr;
+}
diff --git a/core/fxcrt/fx_guid.h b/core/fxcrt/fx_guid.h
new file mode 100644
index 0000000..e80efc4
--- /dev/null
+++ b/core/fxcrt/fx_guid.h
@@ -0,0 +1,22 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FXCRT_FX_GUID_H_
+#define CORE_FXCRT_FX_GUID_H_
+
+#include "core/fxcrt/fx_string.h"
+
+struct FX_GUID {
+  uint32_t data1;
+  uint16_t data2;
+  uint16_t data3;
+  uint8_t data4[8];
+};
+
+void FX_GUID_CreateV4(FX_GUID* pGUID);
+CFX_ByteString FX_GUID_ToString(const FX_GUID* pGUID, bool bSeparator = true);
+
+#endif  // CORE_FXCRT_FX_GUID_H_
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index b68be12..6c70a3d 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -14,6 +14,7 @@
 #include "core/fxcrt/cfx_decimal.h"
 #include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_guid.h"
 #include "fxjs/cfxjse_arguments.h"
 #include "fxjs/cfxjse_class.h"
 #include "fxjs/cfxjse_value.h"